@@ -269,16 +269,6 @@ def address_resolve(hostname)
269
269
::Resolv . getaddresses ( hostname )
270
270
end
271
271
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
-
282
272
# Wait for the specified IO to become ready for the specified events.
283
273
#
284
274
# @public Since *Async v2*.
@@ -295,7 +285,7 @@ def io_wait(io, events, timeout = nil)
295
285
timer = @timers . after ( timeout ) do
296
286
fiber . transfer
297
287
end
298
- elsif timeout = get_timeout ( io )
288
+ elsif timeout = io . timeout
299
289
# Otherwise, if we default to the io's timeout, we raise an exception:
300
290
timer = @timers . after ( timeout ) do
301
291
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)
320
310
def io_read ( io , buffer , length , offset = 0 )
321
311
fiber = Fiber . current
322
312
323
- if timeout = get_timeout ( io )
313
+ if timeout = io . timeout
324
314
timer = @timers . after ( timeout ) do
325
315
fiber . raise ( ::IO ::TimeoutError , "Timeout (#{ timeout } s) while waiting for IO to become readable!" )
326
316
end
@@ -344,7 +334,7 @@ def io_read(io, buffer, length, offset = 0)
344
334
def io_write ( io , buffer , length , offset = 0 )
345
335
fiber = Fiber . current
346
336
347
- if timeout = get_timeout ( io )
337
+ if timeout = io . timeout
348
338
timer = @timers . after ( timeout ) do
349
339
fiber . raise ( ::IO ::TimeoutError , "Timeout (#{ timeout } s) while waiting for IO to become writable!" )
350
340
end
0 commit comments