Class: Async::IO::Notification
- Inherits:
-
Object
- Object
- Async::IO::Notification
- Defined in:
- lib/async/io/notification.rb
Overview
A cross-reactor/process notification pipe.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ Notification
constructor
A new instance of Notification.
-
#signal ⇒ void
Signal to a given task that it should resume operations.
-
#wait ⇒ Object
Wait for signal to be called.
Constructor Details
#initialize ⇒ Notification
Returns a new instance of Notification.
27 28 29 30 31 32 33 34 |
# File 'lib/async/io/notification.rb', line 27 def initialize pipe = ::IO.pipe @input = pipe.first @output = pipe.last @count = 0 end |
Instance Method Details
#close ⇒ Object
36 37 38 39 |
# File 'lib/async/io/notification.rb', line 36 def close @input.close @output.close end |
#signal ⇒ void
This method returns an undefined value.
Signal to a given task that it should resume operations.
50 51 52 |
# File 'lib/async/io/notification.rb', line 50 def signal @output.write(".") end |
#wait ⇒ Object
Wait for signal to be called.
43 44 45 46 |
# File 'lib/async/io/notification.rb', line 43 def wait wrapper = Async::IO::Generic.new(@input) wrapper.read(1) end |