[macruby-changes] [4404] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 4 01:31:36 PDT 2010


Revision: 4404
          http://trac.macosforge.org/projects/ruby/changeset/4404
Author:   lsansonetti at apple.com
Date:     2010-08-04 01:31:33 -0700 (Wed, 04 Aug 2010)
Log Message:
-----------
raise an exception in case we try to stop the only running thread (patch by watson1978 at gmail.com)

Modified Paths:
--------------
    MacRuby/trunk/thread.c
    MacRuby/trunk/vm.cpp

Modified: MacRuby/trunk/thread.c
===================================================================
--- MacRuby/trunk/thread.c	2010-08-03 21:04:12 UTC (rev 4403)
+++ MacRuby/trunk/thread.c	2010-08-04 08:31:33 UTC (rev 4404)
@@ -788,8 +788,7 @@
 int
 rb_thread_alone()
 {
-    // TODO
-    return 0;
+    return RARRAY_LEN(rb_vm_threads()) <= 1;
 }
 
 /*

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2010-08-03 21:04:12 UTC (rev 4403)
+++ MacRuby/trunk/vm.cpp	2010-08-04 08:31:33 UTC (rev 4404)
@@ -4525,6 +4525,11 @@
 {
     rb_vm_thread_t *t = GET_THREAD();
 
+    if (rb_thread_alone()) {
+	rb_raise(rb_eThreadError,
+		"stopping only thread\n\tnote: use sleep to stop forever");
+    }
+
     pre_wait(t);
     const int code = pthread_cond_wait(&t->sleep_cond, &t->sleep_mutex);
     assert(code == 0 || code == ETIMEDOUT);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100804/30c9488b/attachment.html>


More information about the macruby-changes mailing list