Modified: MacRuby/trunk/thread.c (4421 => 4422)
--- 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;
}