summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'bindings')
-rw-r--r--bindings/c/zmq.h6
-rw-r--r--bindings/cpp/zmq.hpp4
-rw-r--r--bindings/java/Context.cpp4
-rw-r--r--bindings/java/org/zmq/Context.java8
-rw-r--r--bindings/python/pyzmq.cpp13
-rw-r--r--bindings/ruby/rbzmq.cpp11
6 files changed, 29 insertions, 17 deletions
diff --git a/bindings/c/zmq.h b/bindings/c/zmq.h
index 732ecb9..797d060 100644
--- a/bindings/c/zmq.h
+++ b/bindings/c/zmq.h
@@ -91,6 +91,10 @@ extern "C" {
// the peer that the previous recv delivered message from.
#define ZMQ_REP 4
+// Option specifying that the sockets should be pollable. This may be a little
+// less efficient that raw non-pollable sockets.
+#define ZMQ_POLL 1
+
// Prototype for the message body deallocation functions.
// It is deliberately defined in the way to comply with standard C free.
typedef void (zmq_free_fn) (void *data);
@@ -150,7 +154,7 @@ ZMQ_EXPORT int zmq_msg_type (struct zmq_msg_t *msg);
//
// Errors: EINVAL - one of the arguments is less than zero or there are no
// threads declared at all.
-ZMQ_EXPORT void *zmq_init (int app_threads, int io_threads);
+ZMQ_EXPORT void *zmq_init (int app_threads, int io_threads, int flags);
// Deinitialise 0MQ context including all the open sockets. Closing
// sockets after zmq_term has been called will result in undefined behaviour.
diff --git a/bindings/cpp/zmq.hpp b/bindings/cpp/zmq.hpp
index 471d1d8..a9e63b5 100644
--- a/bindings/cpp/zmq.hpp
+++ b/bindings/cpp/zmq.hpp
@@ -180,9 +180,9 @@ namespace zmq
public:
- inline context_t (int app_threads_, int io_threads_)
+ inline context_t (int app_threads_, int io_threads_, int flags_ = 0)
{
- ptr = zmq_init (app_threads_, io_threads_);
+ ptr = zmq_init (app_threads_, io_threads_, flags_);
if (ptr == NULL)
throw error_t ();
}
diff --git a/bindings/java/Context.cpp b/bindings/java/Context.cpp
index 67094e8..d2138c3 100644
--- a/bindings/java/Context.cpp
+++ b/bindings/java/Context.cpp
@@ -52,7 +52,7 @@ static void raise_exception (JNIEnv *env, int err)
}
JNIEXPORT void JNICALL Java_org_zmq_Context_construct (JNIEnv *env, jobject obj,
- jint app_threads, jint io_threads)
+ jint app_threads, jint io_threads, jint flags)
{
if (ctx_handle_fid == NULL) {
jclass cls = env->GetObjectClass (obj);
@@ -62,7 +62,7 @@ JNIEXPORT void JNICALL Java_org_zmq_Context_construct (JNIEnv *env, jobject obj,
env->DeleteLocalRef (cls);
}
- void *ctx = zmq_init (app_threads, io_threads);
+ void *ctx = zmq_init (app_threads, io_threads, flags);
if (ctx == NULL) {
raise_exception (env, errno);
return;
diff --git a/bindings/java/org/zmq/Context.java b/bindings/java/org/zmq/Context.java
index c63ef60..408c6b0 100644
--- a/bindings/java/org/zmq/Context.java
+++ b/bindings/java/org/zmq/Context.java
@@ -24,14 +24,16 @@ public class Context {
System.loadLibrary("jzmq");
}
+ public static final int POLL = 1;
+
/**
* Class constructor.
*
* @param appThreads maximum number of application threads.
* @param ioThreads size of the threads pool to handle I/O operations.
*/
- public Context (int appThreads, int ioThreads) {
- construct (appThreads, ioThreads);
+ public Context (int appThreads, int ioThreads, int flags) {
+ construct (appThreads, ioThreads, flags);
}
/**
@@ -40,7 +42,7 @@ public class Context {
public native long createSocket (int type);
/** Initialize the JNI interface */
- protected native void construct (int appThreads, int ioThreads);
+ protected native void construct (int appThreads, int ioThreads, int flags);
/** Free resources used by JNI driver. */
protected native void finalize ();
diff --git a/bindings/python/pyzmq.cpp b/bindings/python/pyzmq.cpp
index 4bb5653..32f30fe 100644
--- a/bindings/python/pyzmq.cpp
+++ b/bindings/python/pyzmq.cpp
@@ -53,15 +53,16 @@ int context_init (context_t *self, PyObject *args, PyObject *kwdict)
{
int app_threads;
int io_threads;
- static const char *kwlist [] = {"app_threads", "io_threads", NULL};
- if (!PyArg_ParseTupleAndKeywords (args, kwdict, "ii", (char**) kwlist,
- &app_threads, &io_threads)) {
+ int flags = 0;
+ static const char *kwlist [] = {"app_threads", "io_threads", "flags", NULL};
+ if (!PyArg_ParseTupleAndKeywords (args, kwdict, "ii|i", (char**) kwlist,
+ &app_threads, &io_threads, &flags)) {
PyErr_SetString (PyExc_SystemError, "invalid arguments");
return -1;
}
assert (!self->handle);
- self->handle = zmq_init (app_threads, io_threads);
+ self->handle = zmq_init (app_threads, io_threads, flags);
if (!self->handle) {
PyErr_SetString (PyExc_SystemError, strerror (errno));
return -1;
@@ -522,7 +523,9 @@ PyMODINIT_FUNC initlibpyzmq ()
t = PyInt_FromLong (ZMQ_MCAST_LOOP);
PyDict_SetItemString (dict, "MCAST_LOOP", t);
Py_DECREF (t);
-
+ t = PyInt_FromLong (ZMQ_POLL);
+ PyDict_SetItemString (dict, "POLL", t);
+ Py_DECREF (t);
}
#if defined _MSC_VER
diff --git a/bindings/ruby/rbzmq.cpp b/bindings/ruby/rbzmq.cpp
index bf0d9bc..83bb2b6 100644
--- a/bindings/ruby/rbzmq.cpp
+++ b/bindings/ruby/rbzmq.cpp
@@ -38,10 +38,11 @@ static VALUE context_alloc (VALUE class_)
}
static VALUE context_initialize (VALUE self_, VALUE app_threads_,
- VALUE io_threads_)
+ VALUE io_threads_, VALUE flags_)
{
assert (!DATA_PTR (self_));
- void *ctx = zmq_init (NUM2INT (app_threads_), NUM2INT (io_threads_));
+ void *ctx = zmq_init (NUM2INT (app_threads_), NUM2INT (io_threads_),
+ NUM2INT (flags_));
if (!ctx) {
rb_raise (rb_eRuntimeError, strerror (errno));
return Qnil;
@@ -105,8 +106,8 @@ static VALUE socket_setsockopt (VALUE self_, VALUE option_,
rc = zmq_setsockopt (DATA_PTR (self_), NUM2INT (option_),
(void *) &optval, 4);
}
-
break;
+
case ZMQ_IDENTITY:
case ZMQ_SUBSCRIBE:
case ZMQ_UNSUBSCRIBE:
@@ -236,7 +237,7 @@ extern "C" void Init_librbzmq ()
VALUE context_type = rb_define_class ("Context", rb_cObject);
rb_define_alloc_func (context_type, context_alloc);
rb_define_method (context_type, "initialize",
- (VALUE(*)(...)) context_initialize, 2);
+ (VALUE(*)(...)) context_initialize, 3);
VALUE socket_type = rb_define_class ("Socket", rb_cObject);
rb_define_alloc_func (socket_type, socket_alloc);
@@ -274,4 +275,6 @@ extern "C" void Init_librbzmq ()
rb_define_global_const ("PUB", INT2NUM (ZMQ_PUB));
rb_define_global_const ("REQ", INT2NUM (ZMQ_REQ));
rb_define_global_const ("REP", INT2NUM (ZMQ_REP));
+
+ rb_define_global_const ("POLL", INT2NUM (ZMQ_POLL));
}