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



696
697
698
699
700
701
702
703
704
# File 'lib/omq/backend/libzmq/engine.rb', line 696

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