connection close: basing on channels to know whether to execute next tick

This commit is contained in:
HoneyryderChuck 2018-03-11 00:41:16 +00:00
parent d98da33dbe
commit 2557eae5f7
2 changed files with 4 additions and 17 deletions

View File

@ -19,19 +19,15 @@ module HTTPX
def next_tick(timeout: @timeout.timeout)
@selector.select(timeout) do |monitor|
if (channel = monitor.value)
consume(channel)
channel.call
end
monitor.interests = channel.interests
end
end
def close(channel = nil)
if channel
channel.close
else
@channels.each(&:close)
next_tick until @selector.empty?
end
def close
@channels.each(&:close)
next_tick until @channels.empty?
end
def reset
@ -65,10 +61,5 @@ module HTTPX
end
@channels << channel
end
def consume(channel)
ch = catch(:close) { channel.call }
close(ch) if ch
end
end
end

View File

@ -48,10 +48,6 @@ class HTTPX::Selector
@closed = false
end
def empty?
@readers.empty? && @writers.empty?
end
# deregisters +io+ from selectables.
def deregister(io)
@lock.synchronize do