diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-12 20:06:59 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-12 20:06:59 +0000 |
commit | d7a19d03334075e29e14e0e2065d29b73e5d5350 (patch) | |
tree | f8aee31917999e2adab92570fcc437cc4c60b0cb | |
parent | 161b2e264fcfc0ecb046b35245139e02847bbdb0 (diff) | |
download | ruby-d7a19d03334075e29e14e0e2065d29b73e5d5350.tar.gz |
* thread.c (rb_thread_raise): check if target thread is
thrown by another thread or not. [ruby-dev:31371]
* bootstraptest/test_thread.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | bootstraptest/test_thread.rb | 14 | ||||
-rw-r--r-- | thread.c | 7 |
3 files changed, 27 insertions, 2 deletions
@@ -1,3 +1,10 @@ +Mon Aug 13 05:03:53 2007 Koichi Sasada <ko1@atdot.net> + + * thread.c (rb_thread_raise): check if target thread is + thrown by another thread or not. [ruby-dev:31371] + + * bootstraptest/test_thread.rb: add a test for above. + Mon Aug 13 04:35:30 2007 Koichi Sasada <ko1@atdot.net> * compile.c (iseq_peephole_optimize): fix peephole optimization @@ -5,7 +12,6 @@ Mon Aug 13 04:35:30 2007 Koichi Sasada <ko1@atdot.net> * bootstraptest/test_syntax.rb: add a test for above. - Mon Aug 13 04:02:29 2007 Koichi Sasada <ko1@atdot.net> * vm_dump.c (debug_print_pre): fix to show control frame count. diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb index 64d685fa19..40ccbad497 100644 --- a/bootstraptest/test_thread.rb +++ b/bootstraptest/test_thread.rb @@ -169,3 +169,17 @@ assert_equal %q{11}, %q{ Thread.current[:a] }.value + Thread.current[:a] } +assert_equal %q{1000}, %q{ +begin + 1000.times do |i| + begin + Thread.start(Thread.current) {|u| u.raise } + raise + rescue + ensure + end + end +rescue + 1000 +end +}, '[ruby-dev:31371]' @@ -758,12 +758,17 @@ rb_thread_raise(int argc, VALUE *argv, rb_thread_t *th) { VALUE exc; + again: if (rb_thread_dead(th)) { return Qnil; } + if (th->thrown_errinfo != 0 || th->raised_flag) { + rb_thread_schedule(); + goto again; + } + exc = rb_make_exception(argc, argv); - /* TODO: need synchronization if run threads in parallel */ th->thrown_errinfo = exc; rb_thread_ready(th); return Qnil; |