[macruby-changes] [4422] MacRuby/trunk/thread.c
source_changes at macosforge.org
source_changes at macosforge.org
Wed Aug 11 13:42:45 PDT 2010
Revision: 4422
http://trac.macosforge.org/projects/ruby/changeset/4422
Author: martinlagardette at apple.com
Date: 2010-08-11 13:42:44 -0700 (Wed, 11 Aug 2010)
Log Message:
-----------
`Mutex#try_unlock`: Add the mutex to the current thread mutexes on success
- Fixes #847
Modified Paths:
--------------
MacRuby/trunk/thread.c
Modified: MacRuby/trunk/thread.c
===================================================================
--- MacRuby/trunk/thread.c 2010-08-11 01:55:41 UTC (rev 4421)
+++ MacRuby/trunk/thread.c 2010-08-11 20:42:44 UTC (rev 4422)
@@ -1363,10 +1363,18 @@
static VALUE
rb_mutex_trylock(VALUE self, SEL sel)
{
- if (pthread_mutex_trylock(&GetMutexPtr(self)->mutex) == 0) {
- GetMutexPtr(self)->thread = GetThreadPtr(rb_vm_current_thread());
+ rb_vm_mutex_t *m = GetMutexPtr(self);
+
+ if (pthread_mutex_trylock(&m->mutex) == 0) {
+ rb_vm_thread_t *current = GetThreadPtr(rb_vm_current_thread());
+ m->thread = current;
+ if (current->mutexes == Qnil) {
+ GC_WB(¤t->mutexes, rb_ary_new());
+ }
+ rb_ary_push(current->mutexes, self);
return Qtrue;
}
+
return Qfalse;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100811/1e0fa039/attachment.html>
More information about the macruby-changes
mailing list