ruby-changes:25861
From: kosaki <ko1@a...>
Date: Wed, 28 Nov 2012 13:11:07 +0900 (JST)
Subject: [ruby-changes:25861] kosaki:r37918 (trunk): * thread.c (thread_join): A trap handler check was moved from
kosaki 2012-11-28 13:09:38 +0900 (Wed, 28 Nov 2012) New Revision: 37918 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37918 Log: * thread.c (thread_join): A trap handler check was moved from thread_join_m because Thread#value should be raised an exception too. * thread.c (thread_join_m): remove trap handler check. * test/ruby/test_thread.rb (test_thread_join_in_trap): add test for thread#value. * NEWS: documentation fix for the above. Modified files: trunk/ChangeLog trunk/NEWS trunk/test/ruby/test_thread.rb trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 37917) +++ ChangeLog (revision 37918) @@ -1,3 +1,13 @@ +Wed Nov 28 12:54:59 2012 KOSAKI Motohiro <kosaki.motohiro@g...> + + * thread.c (thread_join): A trap handler check was moved from + thread_join_m because Thread#value should be raised an exception + too. + * thread.c (thread_join_m): remove trap handler check. + * test/ruby/test_thread.rb (test_thread_join_in_trap): add test + for thread#value. + * NEWS: documentation fix for the above. + Wed Nov 28 11:07:00 2012 Zachary Scott <zachary@z...> * ext/fiddle/closure.c: Documentation for Fiddle Index: thread.c =================================================================== --- thread.c (revision 37917) +++ thread.c (revision 37918) @@ -740,6 +740,10 @@ if (GET_VM()->main_thread == target_th) { rb_raise(rb_eThreadError, "Target thread must not be main thread"); } + /* When running trap handler */ + if (th->interrupt_mask & TRAP_INTERRUPT_MASK) { + rb_raise(rb_eThreadError, "can't be called from trap context"); + } arg.target = target_th; arg.waiting = th; @@ -822,15 +826,9 @@ thread_join_m(int argc, VALUE *argv, VALUE self) { rb_thread_t *target_th; - rb_thread_t *cur_th = GET_THREAD(); double delay = DELAY_INFTY; VALUE limit; - /* When running trap handler */ - if (cur_th->interrupt_mask & TRAP_INTERRUPT_MASK) { - rb_raise(rb_eThreadError, "can't be called from trap context"); - } - GetThreadPtr(self, target_th); rb_scan_args(argc, argv, "01", &limit); Index: NEWS =================================================================== --- NEWS (revision 37917) +++ NEWS (revision 37918) @@ -164,10 +164,10 @@ * added Thread#backtrace_locations which returns similar information of Kernel#caller_locations. * incompatible changes: - * Thread#join is no longer allowed to be used from trap handler and - raises a ThreadError in such case. - * Thread#join now raises a ThreadError if target thread is the current - or main thread. + * Thread#join and Thread#value is no longer allowed to be used from trap + handler and raises a ThreadError in such case. + * Thread#join and Thread#value now raises a ThreadError if target thread + is the current or main thread. * Time * change return value: @@ -376,7 +376,7 @@ * OpenStruct new methods can conflict with custom attributes named "each_pair", "eql?", "hash" or "to_h". - * Thread#join + * Thread#join, Thread#value See above. Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 37917) +++ test/ruby/test_thread.rb (revision 37918) @@ -874,6 +874,17 @@ t.join } + + assert_raise(ThreadError) { + t = Thread.new{ sleep 0.2; Process.kill(:INT, $$) } + + Signal.trap :INT do + t.value + end + + t.value + } + end def test_thread_join_current -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/