diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-06 06:52:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-06 06:52:01 +0000 |
commit | bb1f1c57823758d2450d184ce7c85beb0d538bf0 (patch) | |
tree | 70b894307235e67b88d28a72ecefcea0986f0c85 /thread.c | |
parent | 6a24fdb09d8f92c8bebcebe13ca424bd64577a44 (diff) | |
download | ruby-bb1f1c57823758d2450d184ce7c85beb0d538bf0.tar.gz |
* eval_load.c (rb_feature_p): check if the feature is loading with
load path. [ruby-dev:31932]
* eval_load.c (load_lock): check the result of barrier waiting.
* thread.c (rb_barrier_wait): check if owned by the current thread.
* thread.c (rb_barrier_release): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -2435,7 +2435,7 @@ thlist_free(void *ptr) } static int -thlist_signal(rb_thread_list_t **list, unsigned int maxth) +thlist_signal(rb_thread_list_t **list, unsigned int maxth, rb_thread_t **woken_thread) { int woken = 0; rb_thread_list_t *q; @@ -2447,6 +2447,7 @@ thlist_signal(rb_thread_list_t **list, unsigned int maxth) ruby_xfree(q); if (th->status != THREAD_KILLED) { rb_thread_ready(th); + if (!woken && woken_thread) *woken_thread = th; if (++woken >= maxth && maxth) break; } } @@ -2507,7 +2508,8 @@ rb_barrier_wait(VALUE self) Data_Get_Struct(self, rb_barrier_t, barrier); if (!barrier->owner || barrier->owner->status == THREAD_KILLED) { barrier->owner = 0; - thlist_signal(&barrier->waiting, 0); + if (thlist_signal(&barrier->waiting, 1, &barrier->owner)) return Qfalse; + return Qtrue; } else { *barrier->tail = q = ALLOC(rb_thread_list_t); @@ -2515,8 +2517,8 @@ rb_barrier_wait(VALUE self) q->next = 0; barrier->tail = &q->next; rb_thread_sleep_forever(); + return barrier->owner == GET_THREAD() ? Qtrue : Qfalse; } - return self; } VALUE @@ -2526,8 +2528,10 @@ rb_barrier_release(VALUE self) unsigned int n; Data_Get_Struct(self, rb_barrier_t, barrier); - barrier->owner = 0; - n = thlist_signal(&barrier->waiting, 0); + if (barrier->owner != GET_THREAD()) { + rb_raise(rb_eThreadError, "not owned"); + } + n = thlist_signal(&barrier->waiting, 0, &barrier->owner); return n ? UINT2NUM(n) : Qfalse; } |