Skip to content

Commit

Permalink
Fix IO#{wait,wait_readable,wait_writable} methods and switch the curr…
Browse files Browse the repository at this point in the history
…ent thread into a sleep state
  • Loading branch information
andrykonchin committed Mar 29, 2024
1 parent d45de4c commit 786d24a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions library/io-wait/wait_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@
-> { @w.wait(-1, 0) }.should raise_error(ArgumentError, "Events must be positive integer!")
end
end

it "changes thread status to 'sleep' when waits for READABLE event" do
t = Thread.new { @r.wait(IO::READABLE, 10) }
sleep 1
t.status.should == 'sleep'
t.kill
t.join # Thread#kill doesn't wait for the thread to end
end

it "changes thread status to 'sleep' when waits for WRITABLE event" do
written_bytes = IOWaitSpec.exhaust_write_buffer(@w)

t = Thread.new { @w.wait(IO::WRITABLE, 10) }
sleep 1
t.status.should == 'sleep'
t.kill
t.join # Thread#kill doesn't wait for the thread to end
end
end

context "[timeout, mode] passed" do
Expand Down

0 comments on commit 786d24a

Please sign in to comment.