class Async::IO::Trap

A cross-reactor/process notification pipe.

def initialize(name)

def initialize(name)
	@name = name
	@notifications = []
end

def install!

def install!
	Signal.trap(@name, &self.method(:trigger))
	
	return self
end

def trap

Block the calling task until the signal occurs.
def trap
	task = Task.current
	task.annotate("waiting for signal #{@name}")
	
	notification = Notification.new
	@notifications << notification
	
	while true
		notification.wait
		yield
	end
ensure
	if notification
		notification.close
		@notifications.delete(notification)
	end
end

def trigger(signal_number = nil)

Returns:
  • (void) -
def trigger(signal_number = nil)
	@notifications.each(&:signal)
end