@@ -269,16 +269,6 @@ def address_resolve(hostname)
269269 ::Resolv . getaddresses ( hostname )
270270 end
271271
272- if IO . method_defined? ( :timeout )
273- private def get_timeout ( io )
274- io . timeout
275- end
276- else
277- private def get_timeout ( io )
278- nil
279- end
280- end
281-
282272 # Wait for the specified IO to become ready for the specified events.
283273 #
284274 # @public Since *Async v2*.
@@ -295,7 +285,7 @@ def io_wait(io, events, timeout = nil)
295285 timer = @timers . after ( timeout ) do
296286 fiber . transfer
297287 end
298- elsif timeout = get_timeout ( io )
288+ elsif timeout = io . timeout
299289 # Otherwise, if we default to the io's timeout, we raise an exception:
300290 timer = @timers . after ( timeout ) do
301291 fiber . raise ( ::IO ::TimeoutError , "Timeout (#{ timeout } s) while waiting for IO to become ready!" )
@@ -320,7 +310,7 @@ def io_wait(io, events, timeout = nil)
320310 def io_read ( io , buffer , length , offset = 0 )
321311 fiber = Fiber . current
322312
323- if timeout = get_timeout ( io )
313+ if timeout = io . timeout
324314 timer = @timers . after ( timeout ) do
325315 fiber . raise ( ::IO ::TimeoutError , "Timeout (#{ timeout } s) while waiting for IO to become readable!" )
326316 end
@@ -344,7 +334,7 @@ def io_read(io, buffer, length, offset = 0)
344334 def io_write ( io , buffer , length , offset = 0 )
345335 fiber = Fiber . current
346336
347- if timeout = get_timeout ( io )
337+ if timeout = io . timeout
348338 timer = @timers . after ( timeout ) do
349339 fiber . raise ( ::IO ::TimeoutError , "Timeout (#{ timeout } s) while waiting for IO to become writable!" )
350340 end
0 commit comments