Sha256: 6452e2b622d5ca942a2d6c500cf806743168bbdd1cc1c48b2bb32f6216778068

Contents?: true

Size: 509 Bytes

Versions: 1

Compression:

Stored size: 509 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.zmq_ctx_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

1 entries across 1 versions & 1 rubygems

Version Path
0mq-0.1.2 lib/0mq/context.rb