Class: Async::Notification

Inherits:
Condition show all
Defined in:
lib/async/notification.rb

Overview

A synchronization primitive, which allows fibers to wait until a notification is received. Does not block the task which signals the notification. Waiting tasks are resumed on next iteration of the reactor.

Direct Known Subclasses

Queue

Defined Under Namespace

Classes: Signal

Instance Method Summary collapse

Methods inherited from Condition

#empty?, #initialize, #wait

Constructor Details

This class inherits a constructor from Async::Condition

Instance Method Details

#signal(value = nil, task: Task.current) ⇒ void

This method returns an undefined value.

Signal to a given task that it should resume operations.



30
31
32
33
34
35
36
37
38
# File 'lib/async/notification.rb', line 30

def signal(value = nil, task: Task.current)
	return if @waiting.empty?
	
	task.reactor << Signal.new(@waiting, value)
	
	@waiting = []
	
	return nil
end