Skip to content

Commit 30e1aef

Browse files
authored
Merge pull request #2151 from bluca/newopts
Problem: no support for new socket and context options
2 parents b6d144b + dd4b348 commit 30e1aef

34 files changed

+1073
-0
lines changed

api/python_cffi.slurp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,6 +2759,26 @@ void *
27592759
bool
27602760
zsock_has_in (void *self);
27612761

2762+
// Get socket option `priority`.
2763+
// Available from libzmq 4.3.0.
2764+
int
2765+
zsock_priority (void *self);
2766+
2767+
// Set socket option `priority`.
2768+
// Available from libzmq 4.3.0.
2769+
void
2770+
zsock_set_priority (void *self, int priority);
2771+
2772+
// Get socket option `reconnect_stop`.
2773+
// Available from libzmq 4.3.0.
2774+
int
2775+
zsock_reconnect_stop (void *self);
2776+
2777+
// Set socket option `reconnect_stop`.
2778+
// Available from libzmq 4.3.0.
2779+
void
2780+
zsock_set_reconnect_stop (void *self, int reconnect_stop);
2781+
27622782
// Set socket option `only_first_subscribe`.
27632783
// Available from libzmq 4.3.0.
27642784
void
@@ -3934,6 +3954,18 @@ void
39343954
int
39353955
zsys_thread_name_prefix (void);
39363956

3957+
// Configure the numeric prefix to each thread created for the internal
3958+
// context's thread pool. This option is only supported on Linux.
3959+
// If the environment variable ZSYS_THREAD_NAME_PREFIX_STR is defined, that
3960+
// provides the default.
3961+
// Note that this method is valid only before any socket is created.
3962+
void
3963+
zsys_set_thread_name_prefix_str (const char *prefix);
3964+
3965+
// Return thread name prefix.
3966+
const char *
3967+
zsys_thread_name_prefix_str (void);
3968+
39373969
// Adds a specific CPU to the affinity list of the ZMQ context thread pool.
39383970
// This option is only supported on Linux.
39393971
// Note that this method is valid only before any socket is created.

api/zsock_option.api

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@
1010

1111
<!-- The following socket options are available in libzmq from version 4.3.0 -->
1212

13+
<method name = "priority" polymorphic = "1">
14+
Get socket option `priority`.
15+
Available from libzmq 4.3.0.
16+
<return type = "integer" fresh = "1" />
17+
</method>
18+
19+
<method name = "set priority" polymorphic = "1">
20+
Set socket option `priority`.
21+
Available from libzmq 4.3.0.
22+
<argument name = "priority" type = "integer" />
23+
</method>
24+
25+
<method name = "reconnect stop" polymorphic = "1">
26+
Get socket option `reconnect_stop`.
27+
Available from libzmq 4.3.0.
28+
<return type = "integer" fresh = "1" />
29+
</method>
30+
31+
<method name = "set reconnect stop" polymorphic = "1">
32+
Set socket option `reconnect_stop`.
33+
Available from libzmq 4.3.0.
34+
<argument name = "reconnect stop" type = "integer" />
35+
</method>
36+
1337
<method name = "set only first subscribe" polymorphic = "1">
1438
Set socket option `only_first_subscribe`.
1539
Available from libzmq 4.3.0.

api/zsys.api

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,20 @@
318318
<return type = "integer" />
319319
</method>
320320

321+
<method name = "set thread name prefix str" singleton = "1" state = "draft">
322+
Configure the numeric prefix to each thread created for the internal
323+
context's thread pool. This option is only supported on Linux.
324+
If the environment variable ZSYS_THREAD_NAME_PREFIX_STR is defined, that
325+
provides the default.
326+
Note that this method is valid only before any socket is created.
327+
<argument name = "prefix" type = "string" />
328+
</method>
329+
330+
<method name = "thread name prefix str" singleton = "1" state = "draft">
331+
Return thread name prefix.
332+
<return type = "string" />
333+
</method>
334+
321335
<method name = "thread affinity cpu add" singleton = "1">
322336
Adds a specific CPU to the affinity list of the ZMQ context thread pool.
323337
This option is only supported on Linux.

bindings/delphi/CZMQ.pas

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,22 @@ interface
15831583
// Check whether the socket has available message to read.
15841584
function HasIn: Boolean;
15851585

1586+
// Get socket option `priority`.
1587+
// Available from libzmq 4.3.0.
1588+
function Priority: Integer;
1589+
1590+
// Set socket option `priority`.
1591+
// Available from libzmq 4.3.0.
1592+
procedure SetPriority(Priority: Integer);
1593+
1594+
// Get socket option `reconnect_stop`.
1595+
// Available from libzmq 4.3.0.
1596+
function ReconnectStop: Integer;
1597+
1598+
// Set socket option `reconnect_stop`.
1599+
// Available from libzmq 4.3.0.
1600+
procedure SetReconnectStop(ReconnectStop: Integer);
1601+
15861602
// Set socket option `only_first_subscribe`.
15871603
// Available from libzmq 4.3.0.
15881604
procedure SetOnlyFirstSubscribe(OnlyFirstSubscribe: Integer);
@@ -4531,6 +4547,22 @@ TZsock = class(TInterfacedObject, IZsock)
45314547
// Check whether the socket has available message to read.
45324548
function HasIn: Boolean;
45334549

4550+
// Get socket option `priority`.
4551+
// Available from libzmq 4.3.0.
4552+
function Priority: Integer;
4553+
4554+
// Set socket option `priority`.
4555+
// Available from libzmq 4.3.0.
4556+
procedure SetPriority(Priority: Integer);
4557+
4558+
// Get socket option `reconnect_stop`.
4559+
// Available from libzmq 4.3.0.
4560+
function ReconnectStop: Integer;
4561+
4562+
// Set socket option `reconnect_stop`.
4563+
// Available from libzmq 4.3.0.
4564+
procedure SetReconnectStop(ReconnectStop: Integer);
4565+
45344566
// Set socket option `only_first_subscribe`.
45354567
// Available from libzmq 4.3.0.
45364568
procedure SetOnlyFirstSubscribe(OnlyFirstSubscribe: Integer);
@@ -5474,6 +5506,16 @@ TZsys = class
54745506
// Return thread name prefix.
54755507
class function ThreadNamePrefix: Integer;
54765508

5509+
// Configure the numeric prefix to each thread created for the internal
5510+
// context's thread pool. This option is only supported on Linux.
5511+
// If the environment variable ZSYS_THREAD_NAME_PREFIX_STR is defined, that
5512+
// provides the default.
5513+
// Note that this method is valid only before any socket is created.
5514+
class procedure SetThreadNamePrefixStr(const Prefix: string);
5515+
5516+
// Return thread name prefix.
5517+
class function ThreadNamePrefixStr: string;
5518+
54775519
// Adds a specific CPU to the affinity list of the ZMQ context thread pool.
54785520
// This option is only supported on Linux.
54795521
// Note that this method is valid only before any socket is created.
@@ -8690,6 +8732,26 @@ function ZFreeString(const str: PAnsiChar): string;
86908732
Result := zsock_has_in(FHandle);
86918733
end;
86928734

8735+
function TZsock.Priority: Integer;
8736+
begin
8737+
Result := zsock_priority(FHandle);
8738+
end;
8739+
8740+
procedure TZsock.SetPriority(Priority: Integer);
8741+
begin
8742+
zsock_set_priority(FHandle, Priority);
8743+
end;
8744+
8745+
function TZsock.ReconnectStop: Integer;
8746+
begin
8747+
Result := zsock_reconnect_stop(FHandle);
8748+
end;
8749+
8750+
procedure TZsock.SetReconnectStop(ReconnectStop: Integer);
8751+
begin
8752+
zsock_set_reconnect_stop(FHandle, ReconnectStop);
8753+
end;
8754+
86938755
procedure TZsock.SetOnlyFirstSubscribe(OnlyFirstSubscribe: Integer);
86948756
begin
86958757
zsock_set_only_first_subscribe(FHandle, OnlyFirstSubscribe);
@@ -9946,6 +10008,19 @@ function ZFreeString(const str: PAnsiChar): string;
994610008
Result := zsys_thread_name_prefix;
994710009
end;
994810010

10011+
class procedure TZsys.SetThreadNamePrefixStr(const Prefix: string);
10012+
var
10013+
__Prefix__: UTF8String;
10014+
begin
10015+
__Prefix__ := UTF8String(Prefix);
10016+
zsys_set_thread_name_prefix_str(PAnsiChar(__Prefix__));
10017+
end;
10018+
10019+
class function TZsys.ThreadNamePrefixStr: string;
10020+
begin
10021+
Result := string(UTF8String(zsys_thread_name_prefix_str));
10022+
end;
10023+
994910024
class procedure TZsys.ThreadAffinityCpuAdd(Cpu: Integer);
995010025
begin
995110026
zsys_thread_affinity_cpu_add(Cpu);

bindings/delphi/libczmq.pas

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,6 +2223,22 @@ interface
22232223
// Check whether the socket has available message to read.
22242224
function zsock_has_in(self: PZsock): Boolean; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
22252225

2226+
// Get socket option `priority`.
2227+
// Available from libzmq 4.3.0.
2228+
function zsock_priority(self: PZsock): Integer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
2229+
2230+
// Set socket option `priority`.
2231+
// Available from libzmq 4.3.0.
2232+
procedure zsock_set_priority(self: PZsock; Priority: Integer); cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
2233+
2234+
// Get socket option `reconnect_stop`.
2235+
// Available from libzmq 4.3.0.
2236+
function zsock_reconnect_stop(self: PZsock): Integer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
2237+
2238+
// Set socket option `reconnect_stop`.
2239+
// Available from libzmq 4.3.0.
2240+
procedure zsock_set_reconnect_stop(self: PZsock; ReconnectStop: Integer); cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
2241+
22262242
// Set socket option `only_first_subscribe`.
22272243
// Available from libzmq 4.3.0.
22282244
procedure zsock_set_only_first_subscribe(self: PZsock; OnlyFirstSubscribe: Integer); cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
@@ -3184,6 +3200,16 @@ interface
31843200
// Return thread name prefix.
31853201
function zsys_thread_name_prefix: Integer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
31863202

3203+
// Configure the numeric prefix to each thread created for the internal
3204+
// context's thread pool. This option is only supported on Linux.
3205+
// If the environment variable ZSYS_THREAD_NAME_PREFIX_STR is defined, that
3206+
// provides the default.
3207+
// Note that this method is valid only before any socket is created.
3208+
procedure zsys_set_thread_name_prefix_str(Prefix: PAnsiChar); cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
3209+
3210+
// Return thread name prefix.
3211+
function zsys_thread_name_prefix_str: PAnsiChar; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};
3212+
31873213
// Adds a specific CPU to the affinity list of the ZMQ context thread pool.
31883214
// This option is only supported on Linux.
31893215
// Note that this method is valid only before any socket is created.

bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_Zsock.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,32 @@ Java_org_zeromq_czmq_Zsock__1_1hasIn (JNIEnv *env, jclass c, jlong self)
373373
return has_in_;
374374
}
375375

376+
JNIEXPORT jint JNICALL
377+
Java_org_zeromq_czmq_Zsock__1_1priority (JNIEnv *env, jclass c, jlong self)
378+
{
379+
jint priority_ = (jint) zsock_priority ((zsock_t *) (intptr_t) self);
380+
return priority_;
381+
}
382+
383+
JNIEXPORT void JNICALL
384+
Java_org_zeromq_czmq_Zsock__1_1setPriority (JNIEnv *env, jclass c, jlong self, jint priority)
385+
{
386+
zsock_set_priority ((zsock_t *) (intptr_t) self, (int) priority);
387+
}
388+
389+
JNIEXPORT jint JNICALL
390+
Java_org_zeromq_czmq_Zsock__1_1reconnectStop (JNIEnv *env, jclass c, jlong self)
391+
{
392+
jint reconnect_stop_ = (jint) zsock_reconnect_stop ((zsock_t *) (intptr_t) self);
393+
return reconnect_stop_;
394+
}
395+
396+
JNIEXPORT void JNICALL
397+
Java_org_zeromq_czmq_Zsock__1_1setReconnectStop (JNIEnv *env, jclass c, jlong self, jint reconnect_stop)
398+
{
399+
zsock_set_reconnect_stop ((zsock_t *) (intptr_t) self, (int) reconnect_stop);
400+
}
401+
376402
JNIEXPORT void JNICALL
377403
Java_org_zeromq_czmq_Zsock__1_1setOnlyFirstSubscribe (JNIEnv *env, jclass c, jlong self, jint only_first_subscribe)
378404
{

bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_Zsys.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@ Java_org_zeromq_czmq_Zsys__1_1threadNamePrefix (JNIEnv *env, jclass c)
267267
return thread_name_prefix_;
268268
}
269269

270+
JNIEXPORT void JNICALL
271+
Java_org_zeromq_czmq_Zsys__1_1setThreadNamePrefixStr (JNIEnv *env, jclass c, jstring prefix)
272+
{
273+
char *prefix_ = (char *) (*env)->GetStringUTFChars (env, prefix, NULL);
274+
zsys_set_thread_name_prefix_str (prefix_);
275+
(*env)->ReleaseStringUTFChars (env, prefix, prefix_);
276+
}
277+
278+
JNIEXPORT jstring JNICALL
279+
Java_org_zeromq_czmq_Zsys__1_1threadNamePrefixStr (JNIEnv *env, jclass c)
280+
{
281+
char *thread_name_prefix_str_ = (char *) zsys_thread_name_prefix_str ();
282+
jstring return_string_ = (*env)->NewStringUTF (env, thread_name_prefix_str_);
283+
return return_string_;
284+
}
285+
270286
JNIEXPORT void JNICALL
271287
Java_org_zeromq_czmq_Zsys__1_1threadAffinityCpuAdd (JNIEnv *env, jclass c, jint cpu)
272288
{

bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/Zsock.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,38 @@ public boolean hasIn () {
485485
return __hasIn (self);
486486
}
487487
/*
488+
Get socket option `priority`.
489+
Available from libzmq 4.3.0.
490+
*/
491+
native static int __priority (long self);
492+
public int priority () {
493+
return __priority (self);
494+
}
495+
/*
496+
Set socket option `priority`.
497+
Available from libzmq 4.3.0.
498+
*/
499+
native static void __setPriority (long self, int priority);
500+
public void setPriority (int priority) {
501+
__setPriority (self, priority);
502+
}
503+
/*
504+
Get socket option `reconnect_stop`.
505+
Available from libzmq 4.3.0.
506+
*/
507+
native static int __reconnectStop (long self);
508+
public int reconnectStop () {
509+
return __reconnectStop (self);
510+
}
511+
/*
512+
Set socket option `reconnect_stop`.
513+
Available from libzmq 4.3.0.
514+
*/
515+
native static void __setReconnectStop (long self, int reconnectStop);
516+
public void setReconnectStop (int reconnectStop) {
517+
__setReconnectStop (self, reconnectStop);
518+
}
519+
/*
488520
Set socket option `only_first_subscribe`.
489521
Available from libzmq 4.3.0.
490522
*/

bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/Zsys.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,24 @@ public static int threadNamePrefix () {
322322
return __threadNamePrefix ();
323323
}
324324
/*
325+
Configure the numeric prefix to each thread created for the internal
326+
context's thread pool. This option is only supported on Linux.
327+
If the environment variable ZSYS_THREAD_NAME_PREFIX_STR is defined, that
328+
provides the default.
329+
Note that this method is valid only before any socket is created.
330+
*/
331+
native static void __setThreadNamePrefixStr (String prefix);
332+
public static void setThreadNamePrefixStr (String prefix) {
333+
__setThreadNamePrefixStr (prefix);
334+
}
335+
/*
336+
Return thread name prefix.
337+
*/
338+
native static String __threadNamePrefixStr ();
339+
public static String threadNamePrefixStr () {
340+
return __threadNamePrefixStr ();
341+
}
342+
/*
325343
Adds a specific CPU to the affinity list of the ZMQ context thread pool.
326344
This option is only supported on Linux.
327345
Note that this method is valid only before any socket is created.

0 commit comments

Comments
 (0)