mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4ed6a88b74
commit
694c77633c
4 changed files with 30 additions and 11 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Wed Nov 28 12:54:59 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||
|
||||
* 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@zacharyscott.net>
|
||||
|
||||
* ext/fiddle/closure.c: Documentation for Fiddle
|
||||
|
|
10
NEWS
10
NEWS
|
@ -164,10 +164,10 @@ with all sufficient information, see the ChangeLog file.
|
|||
* 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 @@ with all sufficient information, see the ChangeLog file.
|
|||
* OpenStruct new methods can conflict with custom attributes named
|
||||
"each_pair", "eql?", "hash" or "to_h".
|
||||
|
||||
* Thread#join
|
||||
* Thread#join, Thread#value
|
||||
|
||||
See above.
|
||||
|
||||
|
|
|
@ -874,6 +874,17 @@ class TestThreadGroup < Test::Unit::TestCase
|
|||
|
||||
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
|
||||
|
|
10
thread.c
10
thread.c
|
@ -740,6 +740,10 @@ thread_join(rb_thread_t *target_th, double delay)
|
|||
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 @@ static VALUE
|
|||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue