Class: Flatware::Poller
- Inherits:
-
Object
- Object
- Flatware::Poller
- Defined in:
- lib/flatware/poller.rb
Instance Attribute Summary collapse
-
#sockets ⇒ Object
readonly
Returns the value of attribute sockets.
-
#zmq_poller ⇒ Object
readonly
Returns the value of attribute zmq_poller.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(*sockets) ⇒ Poller
constructor
A new instance of Poller.
Constructor Details
#initialize(*sockets) ⇒ Poller
Returns a new instance of Poller.
4 5 6 7 8 |
# File 'lib/flatware/poller.rb', line 4 def initialize(*sockets) @sockets = sockets @zmq_poller = ZMQ::Poller.new register_sockets end |
Instance Attribute Details
#sockets ⇒ Object (readonly)
Returns the value of attribute sockets.
3 4 5 |
# File 'lib/flatware/poller.rb', line 3 def sockets @sockets end |
#zmq_poller ⇒ Object (readonly)
Returns the value of attribute zmq_poller.
3 4 5 |
# File 'lib/flatware/poller.rb', line 3 def zmq_poller @zmq_poller end |
Instance Method Details
#each(&block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/flatware/poller.rb', line 10 def each(&block) while (result = zmq_poller.poll) != 0 raise Error, ZMQ::Util.error_string, caller if result == -1 for socket in zmq_poller.readables.map &find_wrapped_socket yield socket end end end |