1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* thread.c (thlist_signal): clears the woken thread if nothing woke.

* thread.c (rb_barrier_wait): achieves the lock if no thread was
  waiting yet.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-09-26 08:02:07 +00:00
parent 3deb806a06
commit f8718692a2
2 changed files with 13 additions and 3 deletions

View file

@ -1,3 +1,10 @@
Fri Sep 26 17:02:04 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* thread.c (thlist_signal): clears the woken thread if nothing woke.
* thread.c (rb_barrier_wait): achieves the lock if no thread was
waiting yet.
Fri Sep 26 12:04:07 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/curses/curses.c: should include <ruby/io.h>.

View file

@ -3076,6 +3076,7 @@ thlist_signal(rb_thread_list_t **list, unsigned int maxth, rb_thread_t **woken_t
if (++woken >= maxth && maxth) break;
}
}
if (!woken && woken_thread) *woken_thread = 0;
return woken;
}
@ -3128,23 +3129,25 @@ rb_barrier_wait(VALUE self)
{
rb_barrier_t *barrier;
rb_thread_list_t *q;
rb_thread_t *th = GET_THREAD();
Data_Get_Struct(self, rb_barrier_t, barrier);
if (!barrier->owner || barrier->owner->status == THREAD_KILLED) {
barrier->owner = 0;
if (thlist_signal(&barrier->waiting, 1, &barrier->owner)) return Qfalse;
barrier->owner = th;
return Qtrue;
}
else if (barrier->owner == GET_THREAD()) {
else if (barrier->owner == th) {
return Qfalse;
}
else {
*barrier->tail = q = ALLOC(rb_thread_list_t);
q->th = GET_THREAD();
q->th = th;
q->next = 0;
barrier->tail = &q->next;
rb_thread_sleep_forever();
return barrier->owner == GET_THREAD() ? Qtrue : Qfalse;
return barrier->owner == th ? Qtrue : Qfalse;
}
}