summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-14 03:20:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-14 03:20:02 +0000
commit50c1985555b00bf8e19646a5aad7e881ac84401b (patch)
tree4d211b196572fc84e12c2c693b0fb474b7dfa2a2 /thread.c
parent23f9e7460462efa9273c05b8c616ca9dfa6e24af (diff)
* load.c (load_unlock): release loading barrier and then remove it
from loading_table if it is not in-use. [Bug #5754] * thread.c (rb_barrier_release, rb_barrier_destroy): return whether any other threads are waiting on it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index 192a96bfe5..ced10c226d 100644
--- a/thread.c
+++ b/thread.c
@@ -3719,18 +3719,31 @@ rb_barrier_wait(VALUE self)
return waiting ? Qnil : Qfalse;
}
+/*
+ * Release a barrrier, and return true if it has waiting threads.
+ */
VALUE
rb_barrier_release(VALUE self)
{
- return rb_mutex_unlock(GetBarrierPtr(self));
+ VALUE mutex = GetBarrierPtr(self);
+ rb_mutex_t *m;
+ rb_mutex_unlock(mutex);
+ GetMutexPtr(mutex, m);
+ return m->cond_waiting > 0 ? Qtrue : Qfalse;
}
+/*
+ * Release and destroy a barrrier, and return true if it has waiting threads.
+ */
VALUE
rb_barrier_destroy(VALUE self)
{
VALUE mutex = GetBarrierPtr(self);
+ rb_mutex_t *m;
DATA_PTR(self) = 0;
- return rb_mutex_unlock(mutex);
+ rb_mutex_unlock(mutex);
+ GetMutexPtr(mutex, m);
+ return m->cond_waiting > 0 ? Qtrue : Qfalse;
}
int