Class: Async::IO::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/async/io/notification.rb

Overview

A cross-reactor/process notification pipe.

Instance Method Summary collapse

Constructor Details

#initializeNotification

Returns a new instance of Notification.



27
28
29
30
31
32
# File 'lib/async/io/notification.rb', line 27

def initialize
  pipe = ::IO.pipe
  
  @input = pipe.first
  @output = pipe.last
end

Instance Method Details

#closeObject



34
35
36
37
# File 'lib/async/io/notification.rb', line 34

def close
  @input.close
  @output.close
end

#signalvoid

This method returns an undefined value.

Signal to a given task that it should resume operations.



48
49
50
# File 'lib/async/io/notification.rb', line 48

def signal
  @output.write(".")
end

#waitObject

Wait for signal to be called.

Returns:

  • (Object)


41
42
43
44
# File 'lib/async/io/notification.rb', line 41

def wait
  wrapper = Async::IO::Generic.new(@input)
  wrapper.read(1)
end