summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-07 12:40:01 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-07 12:40:01 +0000
commit887e1011c3df922cb83e86f5adae852cc06fb481 (patch)
tree042b7148e13d37a2d3e1f504d0e7ba49775105b3 /eval.c
parentc4aee4cf0dc00801c9e813d6928aa5957e5f51f2 (diff)
* eval.c, intern.h, ext/thread/thread.c: should not free queue
while any live threads are waiting. [ruby-dev:30653] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@12469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index e4f3330d9c..164d134872 100644
--- a/eval.c
+++ b/eval.c
@@ -11213,10 +11213,19 @@ 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);