diff options
author | Marius Vollmer <mvo@zagadka.de> | 2002-10-27 20:22:01 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2002-10-27 20:22:01 +0000 |
commit | 402858a4d36c70053d3051eaa96e42442affedd8 (patch) | |
tree | 0d20f44de539c60b94b4e44c6b26fee6af960e7b /libguile/async.c | |
parent | 1ceead47c4e4bbc734a19f51a14502eabfa6bac6 (diff) | |
download | guile-402858a4d36c70053d3051eaa96e42442affedd8.tar.gz |
(scm_async_click): Reset pending_asyncs, handle
signal_asyncs. Don't set cdr of a non-signal async to #f.
(scm_i_queue_async_cell): Do not check cdr of cell for #f, queue
always. Set pending_asyncs.
(scm_system_async_mark_for_thread): Check that thread has not
exited.
(scm_unmask_signals, decrease_block): Call scm_async_click after
block_asyncs becomes zero.
Diffstat (limited to 'libguile/async.c')
-rw-r--r-- | libguile/async.c | 76 |
1 files changed, 46 insertions, 30 deletions
diff --git a/libguile/async.c b/libguile/async.c index 48f54c59b..56b2f1776 100644 --- a/libguile/async.c +++ b/libguile/async.c @@ -167,22 +167,34 @@ SCM_DEFINE (scm_run_asyncs, "run-asyncs", 1, 0, 0, void scm_async_click () { - SCM asyncs; + /* Reset pending_asyncs even when asyncs are blocked and not really + executed. + */ + scm_root->pending_asyncs = 0; if (scm_root->block_asyncs == 0) { + SCM asyncs; while (!SCM_NULLP(asyncs = scm_root->active_asyncs)) { scm_root->active_asyncs = SCM_EOL; do { - SCM c = SCM_CDR (asyncs); - SCM_SETCDR (asyncs, SCM_BOOL_F); scm_call_0 (SCM_CAR (asyncs)); - asyncs = c; + asyncs = SCM_CDR (asyncs); } while (!SCM_NULLP(asyncs)); } + for (asyncs = scm_root->signal_asyncs; !SCM_NULLP(asyncs); + asyncs = SCM_CDR (asyncs)) + { + if (!SCM_FALSEP (SCM_CAR (asyncs))) + { + SCM proc = SCM_CAR (asyncs); + SCM_SETCAR (asyncs, SCM_BOOL_F); + scm_call_0 (proc); + } + } } } @@ -206,24 +218,22 @@ SCM_DEFINE (scm_system_async, "system-async", 1, 0, 0, void scm_i_queue_async_cell (SCM c, scm_root_state *root) { - if (SCM_CDR (c) == SCM_BOOL_F) + SCM p = root->active_asyncs; + SCM_SETCDR (c, SCM_EOL); + if (p == SCM_EOL) + root->active_asyncs = c; + else { - SCM p = root->active_asyncs; - SCM_SETCDR (c, SCM_EOL); - if (p == SCM_EOL) - root->active_asyncs = c; - else + SCM pp; + while ((pp = SCM_CDR(p)) != SCM_EOL) { - SCM pp; - while ((pp = SCM_CDR(p)) != SCM_EOL) - { - if (SCM_CAR (p) == SCM_CAR (c)) - return; - p = pp; - } - SCM_SETCDR (p, c); + if (SCM_CAR (p) == SCM_CAR (c)) + return; + p = pp; } + SCM_SETCDR (p, c); } + root->pending_asyncs = 1; } SCM_DEFINE (scm_system_async_mark_for_thread, "system-async-mark", 1, 1, 0, @@ -242,8 +252,11 @@ SCM_DEFINE (scm_system_async_mark_for_thread, "system-async-mark", 1, 1, 0, if (SCM_UNBNDP (thread)) thread = scm_current_thread (); else - SCM_VALIDATE_THREAD (2, thread); - + { + SCM_VALIDATE_THREAD (2, thread); + if (scm_c_thread_exited_p (thread)) + SCM_MISC_ERROR ("thread has already exited", SCM_EOL); + } scm_i_queue_async_cell (scm_cons (proc, SCM_BOOL_F), scm_i_thread_root (thread)); #else @@ -292,6 +305,7 @@ SCM_DEFINE (scm_unmask_signals, "unmask-signals", 0, 0, 0, if (scm_root->block_asyncs == 0) SCM_MISC_ERROR ("signals already unmasked", SCM_EOL); scm_root->block_asyncs = 0; + scm_async_click (); return SCM_UNSPECIFIED; } #undef FUNC_NAME @@ -324,6 +338,8 @@ static void decrease_block (void *unused) { scm_root->block_asyncs--; + if (scm_root->block_asyncs == 0) + scm_async_click (); } SCM_DEFINE (scm_call_with_blocked_asyncs, "call-with-blocked-asyncs", 1, 0, 0, @@ -336,17 +352,17 @@ SCM_DEFINE (scm_call_with_blocked_asyncs, "call-with-blocked-asyncs", 1, 0, 0, return scm_internal_dynamic_wind (increase_block, (scm_t_inner) scm_call_0, decrease_block, - proc, NULL); + (void *)proc, NULL); } #undef FUNC_NAME void * scm_c_call_with_blocked_asyncs (void *(*proc) (void *data), void *data) { - return scm_internal_dynamic_wind (increase_block, - (scm_t_inner) proc, - decrease_block, - data, NULL); + return (void *)scm_internal_dynamic_wind (increase_block, + (scm_t_inner) proc, + decrease_block, + data, NULL); } @@ -362,7 +378,7 @@ SCM_DEFINE (scm_call_with_unblocked_asyncs, "call-with-unblocked-asyncs", 1, 0, return scm_internal_dynamic_wind (decrease_block, (scm_t_inner) scm_call_0, increase_block, - proc, NULL); + (void *)proc, NULL); } #undef FUNC_NAME @@ -372,10 +388,10 @@ scm_c_call_with_unblocked_asyncs (void *(*proc) (void *data), void *data) if (scm_root->block_asyncs == 0) scm_misc_error ("scm_c_call_with_unblocked_asyncs", "asyncs already unblocked", SCM_EOL); - return scm_internal_dynamic_wind (decrease_block, - (scm_t_inner) proc, - increase_block, - data, NULL); + return (void *)scm_internal_dynamic_wind (decrease_block, + (scm_t_inner) proc, + increase_block, + data, NULL); } |