lib/celluloid/zmq/sockets.rb in celluloid-zmq-0.13.0 vs lib/celluloid/zmq/sockets.rb in celluloid-zmq-0.14.0.pre

- old
+ new

@@ -23,10 +23,18 @@ unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::LINGER, value) raise IOError, "couldn't set linger: #{::ZMQ::Util.error_string}" end end + def identity=(value) + @socket.identity = value + end + + def identity + @socket.identity + end + # Bind to the given 0MQ address # Address should be in the form: tcp://1.2.3.4:5678/ def bind(addr) unless ::ZMQ::Util.resultcode_ok? @socket.bind(addr) raise IOError, "couldn't bind to #{addr}: #{::ZMQ::Util.error_string}" @@ -36,19 +44,10 @@ # Close the socket def close @socket.close end - # Does the 0MQ socket support evented operation? - def evented? - actor = Thread.current[:celluloid_actor] - return unless actor - - mailbox = actor.mailbox - mailbox.is_a?(Celluloid::IO::Mailbox) && mailbox.reactor.is_a?(Celluloid::ZMQ::Reactor) - end - # Hide ffi-rzmq internals alias_method :inspect, :to_s end # Readable 0MQ sockets have a read method @@ -66,10 +65,10 @@ super(addr) end # Read a message from the socket def read(buffer = '') - Celluloid.current_actor.wait_readable(@socket) if evented? + ZMQ.wait_readable(@socket) if ZMQ.evented? unless ::ZMQ::Util.resultcode_ok? @socket.recv_string buffer raise IOError, "error receiving ZMQ string: #{::ZMQ::Util.error_string}" end buffer