Class: FiberScheduler::Selector::Waiter
- Inherits:
-
Object
- Object
- FiberScheduler::Selector::Waiter
- Defined in:
- lib/fiber_scheduler/selector.rb
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #each(&block) ⇒ Object
-
#initialize(fiber, events, tail) ⇒ Waiter
constructor
A new instance of Waiter.
- #invalidate ⇒ Object
- #transfer(events) ⇒ Object
Constructor Details
#initialize(fiber, events, tail) ⇒ Waiter
Returns a new instance of Waiter.
29 30 31 32 33 |
# File 'lib/fiber_scheduler/selector.rb', line 29 def initialize(fiber, events, tail) @fiber = fiber @events = events @tail = tail end |
Instance Method Details
#alive? ⇒ Boolean
35 36 37 |
# File 'lib/fiber_scheduler/selector.rb', line 35 def alive? @fiber&.alive? end |
#each(&block) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/fiber_scheduler/selector.rb', line 53 def each(&block) if (fiber = @fiber) yield fiber, @events end @tail&.each(&block) end |
#invalidate ⇒ Object
49 50 51 |
# File 'lib/fiber_scheduler/selector.rb', line 49 def invalidate @fiber = nil end |
#transfer(events) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/fiber_scheduler/selector.rb', line 39 def transfer(events) if (fiber = @fiber) @fiber = nil fiber.transfer(events & @events) if fiber.alive? end @tail&.transfer(events) end |