Sha256: 0fb6cce2e61252af36aebd3e985eeedc1e96ba1c7dd02d151726fcff9baca8fd

Contents?: true

Size: 945 Bytes

Versions: 3

Compression:

Stored size: 945 Bytes

Contents

require 'ffi-rzmq'

require 'celluloid/io'
require 'celluloid/zmq/reactor'
require 'celluloid/zmq/sockets'
require 'celluloid/zmq/version'
require 'celluloid/zmq/waker'

module Celluloid
  # Actors which run alongside 0MQ sockets
  module ZMQ
    class << self
      attr_writer :context

      # Included hook to pull in Celluloid
      def included(klass)
        klass.send :include, ::Celluloid
        klass.use_mailbox { Celluloid::IO::Mailbox.new ZMQ::Reactor.new }
      end

      # Obtain a 0MQ context (or lazily initialize it)
      def context(threads = 1)
        return @context if @context
        @context = ::ZMQ::Context.new(threads)
        at_exit { @context.terminate }
        @context
      end
      alias_method :init, :context
    end

    extend Forwardable

    # Wait for the given IO object to become readable/writeable
    def_delegators 'current_actor.mailbox.reactor', :wait_readable, :wait_writeable
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
celluloid-zmq-0.10.0 lib/celluloid/zmq.rb
dcell-0.9.0 celluloid-zmq/lib/celluloid/zmq.rb
celluloid-zmq-0.9.0 lib/celluloid/zmq.rb