Module: OMQ::Backend::Libzmq

Defined in:
lib/omq/backend/libzmq/engine.rb,
lib/omq/backend/libzmq/native.rb

Defined Under Namespace

Modules: Native Classes: Engine

Class Method Summary collapse

Class Method Details

.contextFFI::Pointer

Returns the shared ZMQ context (one per process, lazily initialized).

Returns:

  • (FFI::Pointer)

    zmq context pointer



708
709
710
711
712
713
714
715
716
# File 'lib/omq/backend/libzmq/engine.rb', line 708

def self.context
  @context ||= Native.zmq_ctx_new.tap do |ctx|
    raise "zmq_ctx_new failed" if ctx.null?
    at_exit do
      Native.zmq_ctx_shutdown(ctx) rescue nil
      Native.zmq_ctx_term(ctx) rescue nil
    end
  end
end