class Async::Condition

@public Since *Async v1*.
A synchronization primitive, which allows fibers to wait until a particular condition is (edge) triggered.

def empty?

@returns [Boolean] If there are no fibers waiting on this condition.
def empty?
	@ready.num_waiting.zero?
end

def exchange

def exchange
	ready = @ready
	@ready = ::Thread::Queue.new
	return ready
end

def initialize

Create a new condition.
def initialize
	@ready = ::Thread::Queue.new
end

def signal(value = nil)

@parameter value [Object | Nil] The value to return to the waiting fibers.
Signal to a given task that it should resume operations.
def signal(value = nil)
	return if empty?
	
	ready = self.exchange
	
	ready.num_waiting.times do
		ready.push(value)
	end
	
	ready.close
	
	return nil
end

def wait

@returns [Object]
Queue up the current fiber and wait on yielding the task.
def wait
	@ready.pop
end

def waiting?

@returns [Boolean] Is any fiber waiting on this notification?
def waiting?
	!self.empty?
end