diff options
author | Marius Vollmer <mvo@zagadka.de> | 2005-03-07 21:30:24 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2005-03-07 21:30:24 +0000 |
commit | a4d106c70e87ee8e5d8aa3a0e3d44218703f1d04 (patch) | |
tree | eb02997854fc4c04e16254b1091b5645daafe355 /libguile/async.h | |
parent | 673ba2da04c2495f905b9e47c2ee820a605aef64 (diff) | |
download | guile-a4d106c70e87ee8e5d8aa3a0e3d44218703f1d04.tar.gz |
* threads.h, async.h, threads.c (SCM_CRITICAL_SECTION_START,
SCM_CRITICAL_SECTION_END): Moved here from threads.h since now
they also block/unblock execution of asyncs and call
scm_async_click which is declared in async.h but threads.h can not
include async.h since async.h already includes threads.h.
(scm_i_critical_section_level): New, for checking mistakes in the
use of the SCM_CRITICAL_SECTION_* macros.
(scm_i_critical_section_mutex): Make it a recursive mutex so that
critical sections can be nested.
* threads.h, threads.c (scm_frame_lock_mutex): New.
(scm_frame_critical_section): Take mutex as argument.
(framed_critical_section_mutex): New, used as default for above.
(scm_init_threads): Initialize it.
(scm_threads_prehistory): Do not initialize thread_admin_mutex and
scm_i_critical_section_mutex; both are initialized statically.
Diffstat (limited to 'libguile/async.h')
-rw-r--r-- | libguile/async.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libguile/async.h b/libguile/async.h index fca230382..e6d71520e 100644 --- a/libguile/async.h +++ b/libguile/async.h @@ -51,6 +51,32 @@ void *scm_c_call_with_unblocked_asyncs (void *(*p) (void *d), void *d); void scm_frame_block_asyncs (void); void scm_frame_unblock_asyncs (void); +/* Critical sections */ + +/* XXX - every critical section needs to be examined whether the + requirements for SCM_CRITICAL_SECTION_START/END are fulfilled. See + the manual. +*/ + +/* Defined in threads.c. scm_i_critical_section_level is only used + for error checking and will go away eventually. */ +extern scm_i_pthread_mutex_t scm_i_critical_section_mutex; +extern int scm_i_critical_section_level; + +#define SCM_CRITICAL_SECTION_START \ + do { \ + scm_i_pthread_mutex_lock (&scm_i_critical_section_mutex);\ + SCM_I_CURRENT_THREAD->block_asyncs++; \ + scm_i_critical_section_level++; \ + } while (0) +#define SCM_CRITICAL_SECTION_END \ + do { \ + scm_i_critical_section_level--; \ + SCM_I_CURRENT_THREAD->block_asyncs--; \ + scm_i_pthread_mutex_unlock (&scm_i_critical_section_mutex); \ + scm_async_click (); \ + } while (0) + SCM_API void scm_init_async (void); #if (SCM_ENABLE_DEPRECATED == 1) |