From 02c20b75923e3895a4d41864b9276e4b277283f8 Mon Sep 17 00:00:00 2001 From: Patrik Wenger Date: Thu, 4 Jan 2024 21:41:37 +0100 Subject: [PATCH] Async::IO::CZTopSocket: speed up #wait_readable and #wait_writable --- lib/cztop/async.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/cztop/async.rb b/lib/cztop/async.rb index 1138a00..bed428a 100644 --- a/lib/cztop/async.rb +++ b/lib/cztop/async.rb @@ -49,6 +49,8 @@ def <<(...) def wait_readable(timeout = read_timeout) @io_fd ||= ::IO.for_fd @io.fd, autoclose: false + return true if @io.readable? + if timeout timeout_at = now + timeout @@ -67,6 +69,8 @@ def wait_readable(timeout = read_timeout) def wait_writable(timeout = write_timeout) @io_fd ||= ::IO.for_fd @io.fd, autoclose: false + return true if @io.writable? + if timeout timeout_at = now + timeout