diff options
author | Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> | 2000-11-30 10:26:44 +0000 |
---|---|---|
committer | Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> | 2000-11-30 10:26:44 +0000 |
commit | 21e8f468cf4a1ebad24b286249ae1983b672af47 (patch) | |
tree | 6aaac0ef37a5997b2d2c23e25d785a9586d0cf2a /libguile/coop-threads.c | |
parent | 818febc097198ab0b01cc87e485d2b1a36e70ee1 (diff) | |
download | guile-21e8f468cf4a1ebad24b286249ae1983b672af47.tar.gz |
* coop-threads.c: Don't join finished threads. Thanks to Julian Satchell.
* coop.c: Removed old non-working code.
Diffstat (limited to 'libguile/coop-threads.c')
-rw-r--r-- | libguile/coop-threads.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libguile/coop-threads.c b/libguile/coop-threads.c index 8214584e8..60f07f64e 100644 --- a/libguile/coop-threads.c +++ b/libguile/coop-threads.c @@ -377,11 +377,24 @@ scm_spawn_thread (scm_catch_body_t body, void *body_data, } SCM -scm_join_thread (SCM t) +scm_join_thread (SCM thread) #define FUNC_NAME s_join_thread { - SCM_VALIDATE_THREAD (1,t); - coop_join (SCM_THREAD_DATA (t)); + coop_t *thread_data; + SCM_VALIDATE_THREAD (1, thread); + /* Dirk:FIXME:: SCM_THREAD_DATA is a handle for a thread. It may be that a + * certain thread implementation uses a value of 0 as a valid thread handle. + * With the following code, this thread would always be considered finished. + */ + /* Dirk:FIXME:: With preemptive threading, a thread may finish immediately + * after SCM_THREAD_DATA is read. Thus, it must be guaranteed that the + * handle remains valid until the thread-object is garbage collected, or + * a mutex has to be used for reading and modifying SCM_THREAD_DATA. + */ + thread_data = SCM_THREAD_DATA (thread); + if (thread_data) + /* The thread is still alive */ + coop_join (thread_data); return SCM_BOOL_T; } #undef FUNC_NAME |