Module: Celluloid::ZMQ
- Defined in:
- lib/celluloid/zmq.rb,
lib/celluloid/zmq/waker.rb,
lib/celluloid/zmq/mailbox.rb,
lib/celluloid/zmq/reactor.rb,
lib/celluloid/zmq/sockets.rb,
lib/celluloid/zmq/version.rb
Overview
Actors which run alongside 0MQ sockets
Defined Under Namespace
Modules: ReadableSocket, WritableSocket Classes: DealerSocket, Mailbox, PubSocket, PullSocket, PushSocket, Reactor, RepSocket, ReqSocket, RouterSocket, Socket, SubSocket, Waker, XPubSocket
Constant Summary collapse
- UninitializedError =
Class.new StandardError
- DeadWakerError =
You can’t wake the dead
Class.new IOError
- VERSION =
"0.16.1"
Class Attribute Summary collapse
Class Method Summary collapse
-
.evented? ⇒ Boolean
Is this a Celluloid::ZMQ evented actor?.
-
.included(klass) ⇒ Object
Included hook to pull in Celluloid.
-
.init(worker_threads = 1) ⇒ Object
Obtain a 0MQ context.
- .terminate ⇒ Object
- .wait_readable(socket) ⇒ Object
- .wait_writable(socket) ⇒ Object
Class Attribute Details
.context ⇒ Object
29 30 31 32 |
# File 'lib/celluloid/zmq.rb', line 29 def context raise UninitializedError, "you must initialize Celluloid::ZMQ by calling Celluloid::ZMQ.init" unless @context @context end |
Class Method Details
.evented? ⇒ Boolean
Is this a Celluloid::ZMQ evented actor?
41 42 43 44 |
# File 'lib/celluloid/zmq.rb', line 41 def self.evented? actor = Thread.current[:celluloid_actor] actor.mailbox.is_a?(Celluloid::ZMQ::Mailbox) end |
.included(klass) ⇒ Object
Included hook to pull in Celluloid
19 20 21 22 |
# File 'lib/celluloid/zmq.rb', line 19 def included(klass) klass.send :include, ::Celluloid klass.mailbox_class Celluloid::ZMQ::Mailbox end |
.init(worker_threads = 1) ⇒ Object
Obtain a 0MQ context
25 26 27 |
# File 'lib/celluloid/zmq.rb', line 25 def init(worker_threads = 1) @context ||= ::ZMQ::Context.new(worker_threads) end |
.terminate ⇒ Object
34 35 36 37 |
# File 'lib/celluloid/zmq.rb', line 34 def terminate @context.terminate if @context @context = nil end |
.wait_readable(socket) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/celluloid/zmq.rb', line 46 def wait_readable(socket) if ZMQ.evented? mailbox = Thread.current[:celluloid_mailbox] mailbox.reactor.wait_readable(socket) else raise ArgumentError, "unable to wait for ZMQ sockets outside the event loop" end nil end |
.wait_writable(socket) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/celluloid/zmq.rb', line 57 def wait_writable(socket) if ZMQ.evented? mailbox = Thread.current[:celluloid_mailbox] mailbox.reactor.wait_writable(socket) else raise ArgumentError, "unable to wait for ZMQ sockets outside the event loop" end nil end |