From 16c1dceeec381e0e8733c55c3855aec757378c81 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Thu, 7 Jun 2007 12:40:01 +0000 Subject: * eval.c, intern.h, ext/thread/thread.c: should not free queue while any live threads are waiting. [ruby-dev:30653] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6@12469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index e4f3330d9..164d13487 100644 --- a/eval.c +++ b/eval.c @@ -11212,11 +11212,20 @@ rb_thread_list() VALUE rb_thread_wakeup(thread) VALUE thread; +{ + if (!RTEST(rb_thread_wakeup_alive(thread))) + rb_raise(rb_eThreadError, "killed thread"); + return thread; +} + +VALUE +rb_thread_wakeup_alive(thread) + VALUE thread; { rb_thread_t th = rb_thread_check(thread); if (th->status == THREAD_KILLED) - rb_raise(rb_eThreadError, "killed thread"); + return Qnil; rb_thread_ready(th); return thread; @@ -11291,7 +11300,7 @@ rb_thread_kill(thread) rb_thread_t th = rb_thread_check(thread); kill_thread(th, 0); - return thread; + return thread; } @@ -11644,6 +11653,15 @@ rb_thread_abort_exc_set(thread, val) } +enum rb_thread_status +rb_thread_status(thread) + VALUE thread; +{ + rb_thread_t th = rb_thread_check(thread); + return th->status; +} + + /* * call-seq: * thr.group => thgrp or nil @@ -12152,7 +12170,7 @@ rb_thread_value(thread) */ static VALUE -rb_thread_status(thread) +rb_thread_status_name(thread) VALUE thread; { rb_thread_t th = rb_thread_check(thread); @@ -12179,7 +12197,7 @@ rb_thread_status(thread) * thr.alive? #=> false */ -static VALUE +VALUE rb_thread_alive_p(thread) VALUE thread; { @@ -13013,7 +13031,7 @@ Init_Thread() rb_define_method(rb_cThread, "terminate!", rb_thread_kill_bang, 0); rb_define_method(rb_cThread, "exit!", rb_thread_kill_bang, 0); rb_define_method(rb_cThread, "value", rb_thread_value, 0); - rb_define_method(rb_cThread, "status", rb_thread_status, 0); + rb_define_method(rb_cThread, "status", rb_thread_status_name, 0); rb_define_method(rb_cThread, "join", rb_thread_join_m, -1); rb_define_method(rb_cThread, "alive?", rb_thread_alive_p, 0); rb_define_method(rb_cThread, "stop?", rb_thread_stop_p, 0); -- cgit