Class: OMQ::Rust::Monitor
- Inherits:
-
Object
- Object
- OMQ::Rust::Monitor
- Includes:
- Enumerable
- Defined in:
- lib/omq/rs/socket.rb
Overview
Enumerable stream of socket lifecycle events.
Instance Method Summary collapse
-
#each {|event| ... } ⇒ Enumerator?
Yields monitor events until socket closes.
-
#initialize(socket) ⇒ Monitor
constructor
Creates a monitor for a socket.
-
#recv(timeout: nil) ⇒ Hash?
Receives next monitor event.
-
#recv_nowait ⇒ Hash?
Receives next available monitor event without blocking.
Constructor Details
#initialize(socket) ⇒ Monitor
Creates a monitor for a socket.
Normally obtained through Socket#monitor.
180 181 182 |
# File 'lib/omq/rs/socket.rb', line 180 def initialize(socket) @socket = socket end |
Instance Method Details
#each {|event| ... } ⇒ Enumerator?
Yields monitor events until socket closes.
204 205 206 207 208 209 210 211 212 |
# File 'lib/omq/rs/socket.rb', line 204 def each return enum_for(__method__) unless block_given? while (event = recv) yield event end rescue IOError raise unless @socket.closed? end |
#recv(timeout: nil) ⇒ Hash?
Receives next monitor event.
189 190 191 |
# File 'lib/omq/rs/socket.rb', line 189 def recv(timeout: nil) @socket.monitor_event(timeout: timeout) end |
#recv_nowait ⇒ Hash?
Receives next available monitor event without blocking.
196 197 198 |
# File 'lib/omq/rs/socket.rb', line 196 def recv_nowait @socket.try_monitor_event end |