1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 09:40:25 +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:
Mark H Weaver 2013-11-17 04:00:29 -05:00
parent 1e42832af0
commit e676a4c342
3 changed files with 33 additions and 0 deletions

View file

@ -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)
{