Module: Celluloid::ZMQ
- Defined in:
- lib/celluloid/zmq.rb,
lib/celluloid/zmq/waker.rb,
lib/celluloid/zmq/sockets.rb,
lib/celluloid/zmq/version.rb,
lib/celluloid/zmq/mailbox.rb,
lib/celluloid/zmq/reactor.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
Constant Summary
- DeadWakerError =
You can't wake the dead
Class.new IOError
- VERSION =
"0.14.0"
Class Attribute Summary (collapse)
-
+ (Object) context(worker_threads = 1)
(also: init)
Obtain a 0MQ context (or lazily initialize it).
Class Method Summary (collapse)
-
+ (Boolean) evented?
Is this a Celluloid::ZMQ evented actor?.
-
+ (Object) included(klass)
Included hook to pull in Celluloid.
- + (Object) terminate
- + (Object) wait_readable(socket)
- + (Object) wait_writable(socket)
Class Attribute Details
+ (Object) context(worker_threads = 1) Also known as: init
Obtain a 0MQ context (or lazily initialize it)
23 24 25 26 |
# File 'lib/celluloid/zmq.rb', line 23 def context(worker_threads = 1) return @context if @context @context = ::ZMQ::Context.new(worker_threads) end |
Class Method Details
+ (Boolean) evented?
Is this a Celluloid::ZMQ evented actor?
35 36 37 38 |
# File 'lib/celluloid/zmq.rb', line 35 def self.evented? actor = Thread.current[:celluloid_actor] actor.mailbox.is_a?(Celluloid::ZMQ::Mailbox) end |
+ (Object) included(klass)
Included hook to pull in Celluloid
17 18 19 20 |
# File 'lib/celluloid/zmq.rb', line 17 def included(klass) klass.send :include, ::Celluloid klass.mailbox_class Celluloid::ZMQ::Mailbox end |
+ (Object) terminate
29 30 31 |
# File 'lib/celluloid/zmq.rb', line 29 def terminate @context.terminate end |
+ (Object) wait_readable(socket)
40 41 42 43 44 45 46 47 48 |
# File 'lib/celluloid/zmq.rb', line 40 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 |
+ (Object) wait_writable(socket)
51 52 53 54 55 56 57 58 59 |
# File 'lib/celluloid/zmq.rb', line 51 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 |