Sha256: f70c796bdf5facff6bd68caa0f356a70e6cf6d2414e34cbec0826e43f470fe59
Contents?: true
Size: 744 Bytes
Versions: 3
Compression:
Stored size: 744 Bytes
Contents
module Buster class Poller def initialize @poller = ZMQ::Poller.new end def start @run = true while @run @poller.poll(500) @poller.readables.each do |socket| action = @readable_actions[socket] action.call(socket) if action end end end def stop @run = false end def register(socket, &block) @poller.register(socket, ZMQ::POLLIN) readable_actions[socket] = block end def pipe(incoming, outgoing) register(incoming) do |s| s.recv_strings(msgs = []) outgoing.send_strings(msgs, ZMQ::NOBLOCK) end end private def readable_actions @readable_actions ||= {} end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
buster-0.1.3 | lib/buster/poller.rb |
buster-0.1.2 | lib/buster/poller.rb |
buster-0.1.1 | lib/buster/poller.rb |