mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 17:43:59 +02:00
* thread.c (rb_uninterruptible): helper function for providing
temporary async_interrupt_timing(Object => :defer) * io.c (rb_f_p): use rb_uninterruptible. * io.c (rb_f_p_internal): helper function for rb_f_p(). * io.c (struct rb_f_p_arg): new struct for rb_f_p_internal. * test/ruby/test_thread.rb (test_async_interrupt_and_p): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
def63c3466
commit
fe6b2e20e9
5 changed files with 78 additions and 15 deletions
|
@ -637,6 +637,26 @@ class TestThread < Test::Unit::TestCase
|
|||
INPUT
|
||||
end
|
||||
|
||||
def test_async_interrupt_and_p
|
||||
assert_in_out_err([], <<-INPUT, %w(:ok :ok), [])
|
||||
th_waiting = true
|
||||
|
||||
t = Thread.new {
|
||||
Thread.async_interrupt_timing(RuntimeError => :on_blocking) {
|
||||
nil while th_waiting
|
||||
# p shouldn't provide interruptible point
|
||||
p :ok
|
||||
p :ok
|
||||
}
|
||||
}
|
||||
|
||||
sleep 0.1
|
||||
t.raise RuntimeError
|
||||
th_waiting = false
|
||||
t.join rescue nil
|
||||
INPUT
|
||||
end
|
||||
|
||||
def test_async_interrupted?
|
||||
q = Queue.new
|
||||
Thread.async_interrupt_timing(RuntimeError => :defer){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue