Make Thread#join always convert its argument, as before 70f08f1eed
This commit is contained in:
parent
2b73e6ba71
commit
82998918ef
@ -22,11 +22,10 @@ describe "Thread#join" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "raises TypeError if the argument is not a valid timeout" do
|
it "raises TypeError if the argument is not a valid timeout" do
|
||||||
t = Thread.new { sleep }
|
t = Thread.new { }
|
||||||
|
t.join
|
||||||
-> { t.join(:foo) }.should raise_error TypeError
|
-> { t.join(:foo) }.should raise_error TypeError
|
||||||
-> { t.join("bar") }.should raise_error TypeError
|
-> { t.join("bar") }.should raise_error TypeError
|
||||||
t.kill
|
|
||||||
t.join
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns nil if it is not finished when given a timeout" do
|
it "returns nil if it is not finished when given a timeout" do
|
||||||
|
11
thread.c
11
thread.c
@ -1313,6 +1313,17 @@ thread_join_m(int argc, VALUE *argv, VALUE self)
|
|||||||
timeout = argv[0];
|
timeout = argv[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert the timeout eagerly, so it's always converted and deterministic
|
||||||
|
if (timeout == Qnil) {
|
||||||
|
/* unlimited */
|
||||||
|
}
|
||||||
|
else if (FIXNUM_P(timeout)) {
|
||||||
|
/* handled directly in thread_join_sleep() */
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timeout = rb_to_float(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
return thread_join(rb_thread_ptr(self), timeout);
|
return thread_join(rb_thread_ptr(self), timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user