Module: Asynchro::Extensions

Defined in:
lib/asynchro/extensions.rb

Instance Method Summary collapse

Instance Method Details

#async_state(&block) ⇒ Object



6
7
8
# File 'lib/asynchro/extensions.rb', line 6

def async_state(&block)
  Asynchro::State.new(&block)
end

#async_tracker(&block) ⇒ Object



2
3
4
# File 'lib/asynchro/extensions.rb', line 2

def async_tracker(&block)
  Asynchro::Tracker.new(&block)
end

#yield_toObject



10
11
12
13
14
15
16
17
18
# File 'lib/asynchro/extensions.rb', line 10

def yield_to
  this = Fiber.current
  
  fiber = Fiber.new do
    yield(lambda { fiber.transfer(this) })
  end

  fiber.transfer(fiber)
end