mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
connection close: basing on channels to know whether to execute next tick
This commit is contained in:
parent
d98da33dbe
commit
2557eae5f7
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user