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) ⇒ Object

Signal to a given task that it should resume operations.



13
14
15
16
17
18
19
# File 'lib/async/notification.rb', line 13

def signal(value = nil, task: Task.current)
	return if @waiting.empty?
	
	Fiber.scheduler.push Signal.new(self.exchange, value)
	
	return nil
end