Module: LibZMQ

Extended by:
FFI::Library
Defined in:
lib/ffi-rzmq-core/libzmq.rb,
lib/ffi-rzmq-core/libzmq4.rb,
lib/ffi-rzmq-core/version.rb,
lib/ffi-rzmq-core/utilities.rb,
lib/ffi-rzmq-core/structures.rb

Overview

Wraps the new API methods available in ZeroMQ 4

Defined Under Namespace

Modules: EventDataLayout, PollItemLayout Classes: EventData, Message, PollItem

Constant Summary collapse

VERSION =
"1.0.7"

Class Method Summary collapse

Class Method Details

.size_of_zmq_msg_tObject

here are the typedefs for zmsg_msg_t for all known releases of libzmq grep ‘typedef struct zmq_msg_t’ */include/zmq.h zeromq-3.2.2/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-3.2.3/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-3.2.4/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-3.2.5/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.0.0/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.0.1/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.0.2/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.0.3/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.0.4/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.0.5/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.0.6/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.0.7/include/zmq.h:typedef struct zmq_msg_t char _ [32]; zmq_msg_t; zeromq-4.1.0/include/zmq.h:typedef struct zmq_msg_t char _ [48]; zmq_msg_t; zeromq-4.1.1/include/zmq.h:typedef struct zmq_msg_t char _ [64]; zmq_msg_t; zeromq-4.1.2/include/zmq.h:typedef struct zmq_msg_t char _ [64]; zmq_msg_t; zeromq-4.1.3/include/zmq.h:typedef struct zmq_msg_t char _ [64]; zmq_msg_t; zeromq-4.1.4/include/zmq.h:typedef struct zmq_msg_t char _ [64]; zmq_msg_t; libzmq/include/zmq.h: typedef union zmq_msg_t {unsigned char _ [64]; void *p; } zmq_msg_t;



34
35
36
37
38
39
40
41
42
# File 'lib/ffi-rzmq-core/structures.rb', line 34

def self.size_of_zmq_msg_t
  if version_number < 040100
    32
  elsif version_number < 040101
    48
  else
    64
  end
end

.terminate_context(context) ⇒ Object

Wrapper function for context termination



133
134
135
# File 'lib/ffi-rzmq-core/libzmq.rb', line 133

def self.terminate_context(context)
  zmq_ctx_destroy(context)
end

.versionObject

Returns a hash of the form => X, :minor => Y, :patch => Z to represent the version of libzmq.

Class method.

Invoke as: ZMQ::LibZMQ.version



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ffi-rzmq-core/utilities.rb', line 11

def self.version
  unless @version
    major = FFI::MemoryPointer.new :int
    minor = FFI::MemoryPointer.new :int
    patch = FFI::MemoryPointer.new :int
    LibZMQ.zmq_version major, minor, patch
    @version = {:major => major.read_int, :minor => minor.read_int, :patch => patch.read_int}
  end

  @version
end

.version3?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ffi-rzmq-core/utilities.rb', line 23

def self.version3?
  version[:major] == 3 && version[:minor] >= 2
end

.version4?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ffi-rzmq-core/utilities.rb', line 27

def self.version4?
  version[:major] == 4
end

.version_numberObject



3
4
5
# File 'lib/ffi-rzmq-core/structures.rb', line 3

def self.version_number
  10000 * version[:major] + 100 * version[:minor] + version[:patch]
end

.version_stringObject



7
8
9
# File 'lib/ffi-rzmq-core/structures.rb', line 7

def self.version_string
  "%d.%d.%d" % version.values_at(:major, :minor, :patch)
end