Sha256: 19e74bd4cd5693c8b4c84daad88efe0ec93b25fb041a58a4f90e13b7f1d2ba70

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

module ZMQ
  
  class Context
    attr_reader :ptr
    
    def initialize
      @ptr = LibZMQ.zmq_ctx_new
    end
    
    # Destroy the ØMQ context.
    def terminate
      if @ptr
        rc = LibZMQ.version4?       ? 
          LibZMQ.zmq_ctx_term(@ptr) : 
          LibZMQ.zmq_term(@ptr)
        ZMQ.error_check true if rc == -1
        
        @ptr = nil
      end
    end
    
    # Create a Socket within this context.
    def socket(type, opts={})
      opts[:context] = self
      ZMQ::Socket.new type, opts
    end
    
  end
  
  DefaultContext = Context.new
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
0mq-0.2.1 lib/0mq/context.rb
0mq-0.2.0 lib/0mq/context.rb