class Async::Condition

A synchronization primative, which allows fibers to wait until a particular condition is triggered.

def initialize

def initialize
	@waiting = []
end

def signal(value = nil)

Returns:
  • (void) -

Other tags:
    See: Task.yield - which is responsible for handling value.

Parameters:
  • value () -- The value to return to the waiting fibers.
def signal(value = nil)
	# TODO: Should we hot-swap @waiting - so that tasks can wait on this condition again?
	while task = @waiting.pop
		task.resume(value)
	end
	
	return nil
end

def wait

Returns:
  • (Object) -
def wait
	@waiting << Fiber.current
	
	Task.yield
end