Class: Async::Wrapper
- Inherits:
-
Object
- Object
- Async::Wrapper
- Defined in:
- lib/async/wrapper.rb
Overview
Represents an asynchronous IO within a reactor.
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
The underlying native
io
. -
#reactor ⇒ Object
readonly
The reactor this wrapper is associated with.
Instance Method Summary collapse
-
#close ⇒ Object
Close the monitor.
-
#initialize(io, reactor = nil) ⇒ Wrapper
constructor
A new instance of Wrapper.
-
#wait_any(interests = :rw, duration = nil) ⇒ Object
Wait fo the io to become either readable or writable.
-
#wait_readable(duration = nil) ⇒ Object
Wait for the io to become readable.
-
#wait_writable(duration = nil) ⇒ Object
Wait for the io to become writable.
Constructor Details
Instance Attribute Details
#io ⇒ Object (readonly)
The underlying native io
.
35 36 37 |
# File 'lib/async/wrapper.rb', line 35 def io @io end |
#reactor ⇒ Object (readonly)
The reactor this wrapper is associated with.
38 39 40 |
# File 'lib/async/wrapper.rb', line 38 def reactor @reactor end |
Instance Method Details
#close ⇒ Object
Close the monitor.
58 59 60 61 62 |
# File 'lib/async/wrapper.rb', line 58 def close close_monitor @io.close if @io end |
#wait_any(interests = :rw, duration = nil) ⇒ Object
Wait fo the io to become either readable or writable.
53 54 55 |
# File 'lib/async/wrapper.rb', line 53 def wait_any(interests = :rw, duration = nil) monitor(interests, duration) end |
#wait_readable(duration = nil) ⇒ Object
Wait for the io to become readable.
41 42 43 |
# File 'lib/async/wrapper.rb', line 41 def wait_readable(duration = nil) wait_any(:r, duration) end |
#wait_writable(duration = nil) ⇒ Object
Wait for the io to become writable.
46 47 48 |
# File 'lib/async/wrapper.rb', line 46 def wait_writable(duration = nil) wait_any(:w, duration) end |