[macruby-changes] [3458] MacRuby/trunk/thread.c
source_changes at macosforge.org
source_changes at macosforge.org
Mon Feb 8 16:44:25 PST 2010
Revision: 3458
http://trac.macosforge.org/projects/ruby/changeset/3458
Author: lsansonetti at apple.com
Date: 2010-02-08 16:44:23 -0800 (Mon, 08 Feb 2010)
Log Message:
-----------
don't always assume that a thread as a group
Modified Paths:
--------------
MacRuby/trunk/thread.c
Modified: MacRuby/trunk/thread.c
===================================================================
--- MacRuby/trunk/thread.c 2010-02-09 00:27:14 UTC (rev 3457)
+++ MacRuby/trunk/thread.c 2010-02-09 00:44:23 UTC (rev 3458)
@@ -59,7 +59,11 @@
rb_vm_thread_pre_init(t, b, argc, argv, rb_vm_create_vm());
// The thread's group is always the parent's one.
- rb_thgroup_add(GetThreadPtr(rb_vm_current_thread())->group, thread);
+ // The parent group might be nil (ex. if created from GCD).
+ VALUE group = GetThreadPtr(rb_vm_current_thread())->group;
+ if (group != Qnil) {
+ rb_thgroup_add(group, thread);
+ }
// Retain the Thread object to avoid a potential GC, the corresponding
// release is done in rb_vm_thread_run().
@@ -1257,15 +1261,17 @@
rb_thread_remove_from_group(VALUE thread)
{
rb_vm_thread_t *t = GetThreadPtr(thread);
- rb_thread_group_t *tg = GetThreadGroupPtr(t->group);
- thgroup_lock(tg);
- if (rb_ary_delete(tg->threads, thread) != thread) {
- printf("trying to remove a thread (%p) from a group that doesn't "\
- "contain it\n", (void *)thread);
- abort();
+ if (t->group != Qnil) {
+ rb_thread_group_t *tg = GetThreadGroupPtr(t->group);
+ thgroup_lock(tg);
+ if (rb_ary_delete(tg->threads, thread) != thread) {
+ printf("trying to remove a thread (%p) from a group that doesn't "\
+ "contain it\n", (void *)thread);
+ abort();
+ }
+ thgroup_unlock(tg);
+ t->group = Qnil;
}
- thgroup_unlock(tg);
- t->group = Qnil;
}
/*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100208/e30b6cda/attachment.html>
More information about the macruby-changes
mailing list