Class: HTTPX::Selector
- Inherits:
-
Object
- Object
- HTTPX::Selector
- Defined in:
- lib/httpx/selector.rb
Instance Method Summary collapse
-
#deregister(io) ⇒ Object
deregisters
io
from selectables. -
#initialize ⇒ Selector
constructor
A new instance of Selector.
-
#register(io) ⇒ Object
register
io
. - #select(interval, &block) ⇒ Object
Constructor Details
#initialize ⇒ Selector
Returns a new instance of Selector.
12 13 14 |
# File 'lib/httpx/selector.rb', line 12 def initialize @selectables = [] end |
Instance Method Details
#deregister(io) ⇒ Object
deregisters io
from selectables.
17 18 19 |
# File 'lib/httpx/selector.rb', line 17 def deregister(io) @selectables.delete(io) end |
#register(io) ⇒ Object
register io
.
22 23 24 25 26 |
# File 'lib/httpx/selector.rb', line 22 def register(io) return if @selectables.include?(io) @selectables << io end |
#select(interval, &block) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/httpx/selector.rb', line 124 def select(interval, &block) # do not cause an infinite loop here. # # this may happen if timeout calculation actually triggered an error which causes # the connections to be reaped (such as the total timeout error) before #select # gets called. return if interval.nil? && @selectables.empty? return select_one(interval, &block) if @selectables.size == 1 select_many(interval, &block) end |