diff options
author | Mikael Djurfeldt <djurfeldt@nada.kth.se> | 2002-12-16 15:24:13 +0000 |
---|---|---|
committer | Mikael Djurfeldt <djurfeldt@nada.kth.se> | 2002-12-16 15:24:13 +0000 |
commit | 0b6843b1eb38ecec4d1c5711745505845a9fc809 (patch) | |
tree | 9cb4a3af452d1baaac3fa27fefbd9d4409c1befd /libguile/threads.c | |
parent | 1b92fb6b4ddc59fa3a6c38d027ed9cddd7084b7e (diff) | |
download | guile-0b6843b1eb38ecec4d1c5711745505845a9fc809.tar.gz |
* threads.c (scm_thread): Removed filed joining_threads.
(thread_print): Print thread number as well as address of thread
structure.
(scm_join_thread): Bugfix.
(scm_lock_mutex, scm_try_mutex, scm_unlock_mutex,
scm_timed_wait_condition_variable, scm_signal_condition_variable,
scm_broadcast_condition_variable): Use the low-level API.
(scm_all_threads): Return copy of thread list (to prevent
unintended destruction).
(scm_threads_prehistory): Initialize heap_mutex of fake thread.
Diffstat (limited to 'libguile/threads.c')
-rw-r--r-- | libguile/threads.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/libguile/threads.c b/libguile/threads.c index 0bc5f07db..dee62c501 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -476,9 +476,10 @@ SCM_DEFINE (scm_join_thread, "join-thread", 1, 0, 0, t = SCM_THREAD_DATA (thread); if (!t->exited) { - scm_thread *c = scm_i_leave_guile (); + scm_thread *c; + c = scm_i_leave_guile (); while (!THREAD_INITIALIZED_P (t)) - SCM_TICK; + scm_i_plugin_thread_yield (); scm_thread_join (t->thread, 0); scm_i_enter_guile (c); } @@ -784,9 +785,7 @@ SCM_DEFINE (scm_lock_mutex, "lock-mutex", 1, 0, 0, else { scm_t_mutex *m = SCM_MUTEX_DATA (mx); - scm_thread *t = scm_i_leave_guile (); - err = scm_i_plugin_mutex_lock (m); - scm_i_enter_guile (t); + err = scm_mutex_lock (m); } if (err) @@ -812,9 +811,7 @@ SCM_DEFINE (scm_try_mutex, "try-mutex", 1, 0, 0, else { scm_t_mutex *m = SCM_MUTEX_DATA (mx); - scm_thread *t = scm_i_leave_guile (); - err = scm_i_plugin_mutex_trylock (m); - scm_i_enter_guile (t); + err = scm_mutex_trylock (m); } if (err == EBUSY) @@ -862,7 +859,7 @@ SCM_DEFINE (scm_unlock_mutex, "unlock-mutex", 1, 0, 0, else { scm_t_mutex *m = SCM_MUTEX_DATA (mx); - err = scm_i_plugin_mutex_unlock (m); + err = scm_mutex_unlock (m); } if (err) @@ -935,9 +932,7 @@ SCM_DEFINE (scm_timed_wait_condition_variable, "wait-condition-variable", 2, 1, { scm_t_cond *c = SCM_CONDVAR_DATA (cv); scm_t_mutex *m = SCM_MUTEX_DATA (mx); - scm_thread *t = scm_i_leave_guile (); - err = scm_i_plugin_cond_wait (c, m); - scm_i_enter_guile (t); + err = scm_cond_wait (c, m); } if (err) @@ -960,7 +955,7 @@ SCM_DEFINE (scm_signal_condition_variable, "signal-condition-variable", 1, 0, 0, else { scm_t_cond *c = SCM_CONDVAR_DATA (cv); - scm_i_plugin_cond_signal (c); + scm_cond_signal (c); } return SCM_BOOL_T; } @@ -977,7 +972,7 @@ SCM_DEFINE (scm_broadcast_condition_variable, "broadcast-condition-variable", 1, else { scm_t_cond *c = SCM_CONDVAR_DATA (cv); - scm_i_plugin_cond_broadcast (c); + scm_cond_broadcast (c); } return SCM_BOOL_T; } @@ -1213,7 +1208,7 @@ SCM_DEFINE (scm_all_threads, "all-threads", 0, 0, 0, "Return a list of all threads.") #define FUNC_NAME s_scm_all_threads { - return all_threads; + return scm_list_copy (all_threads); } #undef FUNC_NAME @@ -1343,7 +1338,9 @@ scm_threads_prehistory () t = malloc (sizeof (scm_thread)); t->base = NULL; t->clear_freelists_p = 0; + scm_i_plugin_mutex_init (&t->heap_mutex, &scm_i_plugin_mutex); scm_setspecific (scm_i_thread_key, t); + scm_i_enter_guile (t); } scm_t_bits scm_tc16_thread; |