mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-08 00:02:42 -04:00
simplified refined IO#wait, as it's designed for a certain niche feature
This commit is contained in:
parent
d3a6edeecb
commit
6fbd8da838
@ -4,19 +4,14 @@ require "io/wait"
|
|||||||
|
|
||||||
module IOExtensions
|
module IOExtensions
|
||||||
refine IO do
|
refine IO do
|
||||||
def wait(timeout = nil, mode = :read)
|
# provides a fallback for rubies where IO#wait isn't implemented,
|
||||||
case mode
|
# but IO#wait_readable and IO#wait_writable are.
|
||||||
when :read
|
def wait(timeout = nil, _mode = :read_write)
|
||||||
wait_readable(timeout)
|
r, w = IO.select([self], [self], nil, timeout)
|
||||||
when :write
|
|
||||||
wait_writable(timeout)
|
|
||||||
when :read_write
|
|
||||||
r, w = IO.select([self], [self], nil, timeout)
|
|
||||||
|
|
||||||
return unless r || w
|
return unless r || w
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user