Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
f25cd6e7
Commit
f25cd6e7
authored
Oct 17, 2017
by
f18m
Committed by
Luca Boccassi
Oct 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Background thread names (#2784)
* Add ZMQ_THREAD_NAME_PREFIX ctx option
parent
9af03e22
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
2 deletions
+26
-2
zmq.h
include/zmq.h
+1
-0
ctx.cpp
src/ctx.cpp
+14
-1
ctx.hpp
src/ctx.hpp
+2
-1
zmq_draft.h
src/zmq_draft.h
+1
-0
test_ctx_options.cpp
tests/test_ctx_options.cpp
+8
-0
No files found.
include/zmq.h
View file @
f25cd6e7
...
...
@@ -613,6 +613,7 @@ ZMQ_EXPORT void zmq_threadclose (void* thread);
#define ZMQ_MSG_T_SIZE 6
#define ZMQ_THREAD_AFFINITY 7
#define ZMQ_THREAD_AFFINITY_DFLT -1
#define ZMQ_THREAD_NAME_PREFIX 8
/* DRAFT Socket methods. */
ZMQ_EXPORT
int
zmq_join
(
void
*
s
,
const
char
*
group
);
...
...
src/ctx.cpp
View file @
f25cd6e7
...
...
@@ -36,6 +36,7 @@
#include <limits>
#include <climits>
#include <new>
#include <sstream>
#include <string.h>
#include "ctx.hpp"
...
...
@@ -256,6 +257,13 @@ int zmq::ctx_t::set (int option_, int optval_)
thread_affinity
=
optval_
;
}
else
if
(
option_
==
ZMQ_THREAD_NAME_PREFIX
&&
optval_
>=
0
)
{
std
::
ostringstream
s
;
s
<<
optval_
;
scoped_lock_t
locker
(
opt_sync
);
thread_name_prefix
=
s
.
str
();
}
else
if
(
option_
==
ZMQ_BLOCKY
&&
optval_
>=
0
)
{
scoped_lock_t
locker
(
opt_sync
);
blocky
=
(
optval_
!=
0
);
...
...
@@ -401,11 +409,16 @@ zmq::object_t *zmq::ctx_t::get_reaper ()
void
zmq
::
ctx_t
::
start_thread
(
thread_t
&
thread_
,
thread_fn
*
tfn_
,
void
*
arg_
)
const
{
static
unsigned
int
nthreads_started
=
0
;
thread_
.
setSchedulingParameters
(
thread_priority
,
thread_sched_policy
,
thread_affinity
);
thread_
.
start
(
tfn_
,
arg_
);
#ifndef ZMQ_HAVE_ANDROID
thread_
.
setThreadName
(
"ZMQ background"
);
std
::
ostringstream
s
;
s
<<
thread_name_prefix
<<
"/ZMQbg/"
<<
nthreads_started
;
thread_
.
setThreadName
(
s
.
str
().
c_str
());
#endif
nthreads_started
++
;
}
void
zmq
::
ctx_t
::
send_command
(
uint32_t
tid_
,
const
command_t
&
command_
)
...
...
src/ctx.hpp
View file @
f25cd6e7
...
...
@@ -211,10 +211,11 @@ namespace zmq
// Is IPv6 enabled on this context?
bool
ipv6
;
// Thread
scheduling
parameters.
// Thread parameters.
int
thread_priority
;
int
thread_sched_policy
;
int
thread_affinity
;
std
::
string
thread_name_prefix
;
// Synchronisation of access to context options.
mutex_t
opt_sync
;
...
...
src/zmq_draft.h
View file @
f25cd6e7
...
...
@@ -93,6 +93,7 @@
#define ZMQ_MSG_T_SIZE 6
#define ZMQ_THREAD_AFFINITY 7
#define ZMQ_THREAD_AFFINITY_DFLT -1
#define ZMQ_THREAD_NAME_PREFIX 8
/* DRAFT Socket methods. */
int
zmq_join
(
void
*
s
,
const
char
*
group
);
...
...
tests/test_ctx_options.cpp
View file @
f25cd6e7
...
...
@@ -124,6 +124,14 @@ void test_ctx_thread_opts(void* ctx)
rc
=
zmq_ctx_set
(
ctx
,
ZMQ_THREAD_AFFINITY
,
cpu_affinity_test
);
assert
(
rc
==
0
);
#endif
#ifdef ZMQ_THREAD_NAME_PREFIX
// test thread name prefix:
rc
=
zmq_ctx_set
(
ctx
,
ZMQ_THREAD_NAME_PREFIX
,
1234
);
assert
(
rc
==
0
);
#endif
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment