ruby-changes:25826
From: kosaki <ko1@a...>
Date: Tue, 27 Nov 2012 11:00:37 +0900 (JST)
Subject: [ruby-changes:25826] kosaki:r37883 (trunk): * thread.c (thread_join): raises ThreadError if target thread
kosaki 2012-11-27 11:00:09 +0900 (Tue, 27 Nov 2012) New Revision: 37883 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37883 Log: * thread.c (thread_join): raises ThreadError if target thread is a current thread. * test/ruby/test_thread.rb (test_thread_join_current): test for the above. * NEWS: news for the above. Modified files: trunk/ChangeLog trunk/NEWS trunk/test/ruby/test_thread.rb trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 37882) +++ ChangeLog (revision 37883) @@ -1,3 +1,11 @@ +Tue Nov 27 09:24:47 2012 KOSAKI Motohiro <kosaki.motohiro@g...> + + * thread.c (thread_join): raises ThreadError if target thread + is a current thread. + * test/ruby/test_thread.rb (test_thread_join_current): + test for the above. + * NEWS: news for the above. + Tue Nov 27 10:37:44 2012 Aaron Patterson <aaron@t...> * ext/fiddle/handle.c: Make Fiddle independent of DL, copy DL::Handle Index: thread.c =================================================================== --- thread.c (revision 37882) +++ thread.c (revision 37883) @@ -736,6 +736,10 @@ rb_thread_t *th = GET_THREAD(); struct join_arg arg; + if (th == target_th) { + rb_raise(rb_eThreadError, "Target thread must not be current thread"); + } + arg.target = target_th; arg.waiting = th; arg.limit = timeofday() + delay; Index: NEWS =================================================================== --- NEWS (revision 37882) +++ NEWS (revision 37883) @@ -160,6 +160,7 @@ * incompatible changes: * Thread#join no longer allows to be used from trap handler. Now it raises ThreadError. + * Thread#join raises ThreadError if target therad is a current thread. * Time * change return value: Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 37882) +++ test/ruby/test_thread.rb (revision 37883) @@ -876,6 +876,9 @@ } end - - + def test_thread_join_current + assert_raises(ThreadError) do + Thread.current.join + end + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/