Class: ZMQ::Context
- Inherits:
-
Object
- Object
- ZMQ::Context
- Defined in:
- lib/0mq/context.rb
Overview
The context object encapsulates all the global state associated with the library.
Instance Attribute Summary collapse
-
#pointer ⇒ Object
readonly
The FFI pointer to the context.
Instance Method Summary collapse
-
#initialize ⇒ Context
constructor
A new instance of Context.
-
#socket(type, opts = {}) ⇒ Object
Create a Socket within this context.
-
#terminate ⇒ Object
Destroy the ØMQ context.
-
#to_ptr ⇒ Object
Returns the context’s FFI pointer.
Constructor Details
Instance Attribute Details
#pointer ⇒ Object (readonly)
The FFI pointer to the context.
9 10 11 |
# File 'lib/0mq/context.rb', line 9 def pointer @pointer end |
Instance Method Details
#socket(type, opts = {}) ⇒ Object
Create a Socket within this context.
28 29 30 31 |
# File 'lib/0mq/context.rb', line 28 def socket(type, opts={}) opts[:context] = self ZMQ::Socket.new type, opts end |
#terminate ⇒ Object
Destroy the ØMQ context.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/0mq/context.rb', line 16 def terminate if @pointer rc = LibZMQ.version4? ? LibZMQ.zmq_ctx_term(@pointer) : LibZMQ.zmq_term(@pointer) ZMQ.error_check true if rc == -1 @pointer = nil end end |
#to_ptr ⇒ Object
Returns the context’s FFI pointer.
34 35 36 |
# File 'lib/0mq/context.rb', line 34 def to_ptr @pointer end |