Module: OMQ::FFI

Defined in:
lib/omq/ffi/engine.rb,
lib/omq/ffi/libzmq.rb

Defined Under Namespace

Modules: Libzmq 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



636
637
638
639
640
641
642
643
644
# File 'lib/omq/ffi/engine.rb', line 636

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