Class: IO::Event::Selector::Select::Waiter
- Inherits:
-
Struct
- Object
- Struct
- IO::Event::Selector::Select::Waiter
- Defined in:
- lib/io/event/selector/select.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#fiber ⇒ Object
Returns the value of attribute fiber.
-
#tail ⇒ Object
Returns the value of attribute tail.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#dispatch(events, &reactivate) ⇒ Object
Dispatch the given events to the list of waiting fibers.
- #each(&block) ⇒ Object
- #invalidate ⇒ Object
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events
107 108 109 |
# File 'lib/io/event/selector/select.rb', line 107 def events @events end |
#fiber ⇒ Object
Returns the value of attribute fiber
107 108 109 |
# File 'lib/io/event/selector/select.rb', line 107 def fiber @fiber end |
#tail ⇒ Object
Returns the value of attribute tail
107 108 109 |
# File 'lib/io/event/selector/select.rb', line 107 def tail @tail end |
Instance Method Details
#alive? ⇒ Boolean
108 109 110 |
# File 'lib/io/event/selector/select.rb', line 108 def alive? self.fiber&.alive? end |
#dispatch(events, &reactivate) ⇒ Object
Dispatch the given events to the list of waiting fibers. If the fiber was not waiting for the given events, it is reactivated by calling the given block.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/io/event/selector/select.rb', line 113 def dispatch(events, &reactivate) # We capture the tail here, because calling reactivate might modify it: tail = self.tail if fiber = self.fiber if fiber.alive? revents = events & self.events if revents.zero? reactivate.call(self) else self.fiber = nil fiber.transfer(revents) end else self.fiber = nil end end tail&.dispatch(events, &reactivate) end |
#each(&block) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/io/event/selector/select.rb', line 138 def each(&block) if fiber = self.fiber yield fiber, self.events end self.tail&.each(&block) end |
#invalidate ⇒ Object
134 135 136 |
# File 'lib/io/event/selector/select.rb', line 134 def invalidate self.fiber = nil end |