Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/async/io/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def wait(timeout = self.timeout, mode = :read)
when :write
wait_writable(timeout)
else
wait_any(:rw, timeout)
wait_any(timeout)
end
rescue TimeoutError
return nil
Expand Down
26 changes: 26 additions & 0 deletions spec/async/io/generic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,32 @@

[reader, writer].each(&:wait)
end

it "can wait for anything" do
reader = reactor.async do |task|
duration = Async::Clock.measure do
input.wait(1, nil)
end

expect(duration).to be >= wait_duration
expect(input.read(1024)).to be == message

input.close
end

writer = reactor.async do |task|
duration = Async::Clock.measure do
output.wait(1, :write)
end

task.sleep(wait_duration)

output.write(message)
output.close
end

[reader, writer].each(&:wait)
end

it "can return nil when timeout is exceeded" do
reader = reactor.async do |task|
Expand Down