From 6419bd82ebd7c6122f09c033ef9123378b0d117c Mon Sep 17 00:00:00 2001 From: Ilya Ponomarev Date: Wed, 18 Oct 2017 11:41:34 +0800 Subject: [PATCH] improve method IoLoopBody#tick --- lib/ione/io/io_reactor.rb | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/ione/io/io_reactor.rb b/lib/ione/io/io_reactor.rb index 61cc4cf..1050e76 100644 --- a/lib/ione/io/io_reactor.rb +++ b/lib/ione/io/io_reactor.rb @@ -512,24 +512,15 @@ def close_sockets def tick readables = [] writables = [] - connecting = [] @sockets.each do |s| - if s.connected? - readables << s - elsif s.connecting? - connecting << s - end - if s.connecting? || s.writable? - writables << s - end + readables << s if s.connected? + writables << s if s.connecting? || s.writable? + s.connect if s.connecting? end - begin r, w, _ = @selector.select(readables, writables, nil, @timeout) - connecting.each { |s| s.connect } - r && r.each { |s| s.read } - w && w.each { |s| s.flush } - rescue IOError, Errno::EBADF - end + r && r.each(&:read) + w && w.each(&:flush) + rescue IOError, Errno::EBADF end def to_s