summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-26 08:02:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-26 08:02:07 +0000
commitf8718692a2ee7e62e2fa3678963c8d71809abb42 (patch)
treeb87fffd965a28d51286347fc3845683a06734cc0
parent3deb806a067dfcf68dd870f518a6eefe6f8794f7 (diff)
* 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
-rw-r--r--ChangeLog7
-rw-r--r--thread.c9
2 files changed, 13 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 751e0d948e..6ecad566d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>.
diff --git a/thread.c b/thread.c
index 964fb7c60a..646223e8f5 100644
--- a/thread.c
+++ b/thread.c
@@ -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;
}
}