From f2fff83e96fe5faea36354993602195881ee8ba3 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 14 Dec 2011 01:20:11 +0000 Subject: * 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 --- thread.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'thread.c') 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 -- cgit v1.2.3