summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-14 01:20:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-14 01:20:11 +0000
commitf2fff83e96fe5faea36354993602195881ee8ba3 (patch)
tree36e76ff6d2283559a20c37a4c5f3f59c0cb48f70 /thread.c
parentaa432d233491abc0d5e271f8e73345edb49348b7 (diff)
downloadruby-f2fff83e96fe5faea36354993602195881ee8ba3.tar.gz
* load.c (load_lock): delete the loading barrier if it has been
destroyed. * thread.c (rb_barrier_wait): return nil for recursive lock instead of false, to distinguish it from destroyed barrier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index 7165905007..192a96bfe5 100644
--- a/thread.c
+++ b/thread.c
@@ -3694,19 +3694,29 @@ rb_barrier_new(void)
return barrier;
}
+/*
+ * Wait a barrier.
+ *
+ * Returns
+ * true: acquired the barrier
+ * false: the barrier was destroyed and no other threads waiting
+ * nil: the barrier was destroyed but still in use
+ */
VALUE
rb_barrier_wait(VALUE self)
{
VALUE mutex = GetBarrierPtr(self);
rb_mutex_t *m;
+ int waiting;
if (!mutex) return Qfalse;
GetMutexPtr(mutex, m);
- if (m->th == GET_THREAD()) return Qfalse;
+ if (m->th == GET_THREAD()) return Qnil;
rb_mutex_lock(mutex);
if (DATA_PTR(self)) return Qtrue;
+ waiting = m->cond_waiting;
rb_mutex_unlock(mutex);
- return Qfalse;
+ return waiting ? Qnil : Qfalse;
}
VALUE