mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 13:30:26 +02:00
Add mutex locking functions that also block asyncs.
* libguile/async.h (scm_i_pthread_mutex_lock_block_asyncs, scm_i_pthread_mutex_unlock_unblock_asyncs): New macros. * libguile/threads.c (do_unlock_with_asyncs): New static helper. (scm_i_dynwind_pthread_mutex_lock_block_asyncs): New function. * libguile/threads.h (scm_i_dynwind_pthread_mutex_lock_block_asyncs): Add prototype.
This commit is contained in:
parent
1e42832af0
commit
e676a4c342
3 changed files with 33 additions and 0 deletions
|
@ -78,6 +78,22 @@ SCM_API void scm_critical_section_end (void);
|
|||
scm_async_click (); \
|
||||
} while (0)
|
||||
|
||||
# define scm_i_pthread_mutex_lock_block_asyncs(m) \
|
||||
do \
|
||||
{ \
|
||||
SCM_I_CURRENT_THREAD->block_asyncs++; \
|
||||
scm_i_pthread_mutex_lock (m); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
# define scm_i_pthread_mutex_unlock_unblock_asyncs(m) \
|
||||
do \
|
||||
{ \
|
||||
scm_i_pthread_mutex_unlock (m); \
|
||||
SCM_I_CURRENT_THREAD->block_asyncs--; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#else /* !BUILDING_LIBGUILE */
|
||||
|
||||
# define SCM_CRITICAL_SECTION_START scm_critical_section_start ()
|
||||
|
|
|
@ -2010,6 +2010,22 @@ scm_pthread_cond_timedwait (scm_i_pthread_cond_t *cond,
|
|||
|
||||
#endif
|
||||
|
||||
static void
|
||||
do_unlock_with_asyncs (void *data)
|
||||
{
|
||||
scm_i_pthread_mutex_unlock ((scm_i_pthread_mutex_t *)data);
|
||||
SCM_I_CURRENT_THREAD->block_asyncs--;
|
||||
}
|
||||
|
||||
void
|
||||
scm_i_dynwind_pthread_mutex_lock_block_asyncs (scm_i_pthread_mutex_t *mutex)
|
||||
{
|
||||
SCM_I_CURRENT_THREAD->block_asyncs++;
|
||||
scm_i_scm_pthread_mutex_lock (mutex);
|
||||
scm_dynwind_unwind_handler (do_unlock_with_asyncs, mutex,
|
||||
SCM_F_WIND_EXPLICITLY);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
scm_std_usleep (unsigned long usecs)
|
||||
{
|
||||
|
|
|
@ -143,6 +143,7 @@ SCM_INTERNAL void scm_init_threads (void);
|
|||
SCM_INTERNAL void scm_init_thread_procs (void);
|
||||
SCM_INTERNAL void scm_init_threads_default_dynamic_state (void);
|
||||
|
||||
SCM_INTERNAL void scm_i_dynwind_pthread_mutex_lock_block_asyncs (scm_i_pthread_mutex_t *mutex);
|
||||
|
||||
#define SCM_THREAD_SWITCHING_CODE \
|
||||
do { } while (0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue