Revision: 4404 http://trac.macosforge.org/projects/ruby/changeset/4404 Author: lsansonetti@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);
participants (1)
-
source_changes@macosforge.org