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
be200896
Unverified
Commit
be200896
authored
Feb 17, 2019
by
Simon Giesecke
Committed by
GitHub
Feb 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3411 from bluca/fix_threads
Problem: non-linux build broken by last PR
parents
484374f2
f83b13b2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
23 deletions
+28
-23
ctx.cpp
src/ctx.cpp
+9
-13
io_thread.cpp
src/io_thread.cpp
+5
-2
thread.cpp
src/thread.cpp
+11
-4
thread.hpp
src/thread.hpp
+2
-3
zmq_utils.cpp
src/zmq_utils.cpp
+1
-1
No files found.
src/ctx.cpp
View file @
be200896
...
...
@@ -422,23 +422,19 @@ void zmq::thread_ctx_t::start_thread (thread_t &thread_,
void
*
arg_
,
const
char
*
name_
)
const
{
static
unsigned
int
nthreads_started
=
0
;
thread_
.
setSchedulingParameters
(
_thread_priority
,
_thread_sched_policy
,
_thread_affinity_cpus
);
char
namebuf
[
16
];
snprintf
(
namebuf
,
sizeof
(
namebuf
),
"0MQ%s%s"
,
name_
?
":"
:
""
,
name_
?
name_
:
""
);
thread_
.
start
(
tfn_
,
arg_
,
namebuf
);
#ifndef ZMQ_HAVE_ANDROID
std
::
ostringstream
s
;
if
(
!
_thread_name_prefix
.
empty
())
s
<<
_thread_name_prefix
<<
"/"
;
s
<<
"ZMQbg/"
<<
nthreads_started
;
thread_
.
setThreadName
(
s
.
str
().
c_str
());
char
namebuf
[
16
]
=
""
;
#ifdef ZMQ_HAVE_WINDOWS
LIBZMQ_UNUSED
(
name_
);
#else
snprintf
(
namebuf
,
sizeof
(
namebuf
),
"%s%sZMQbg%s%s"
,
_thread_name_prefix
.
empty
()
?
""
:
_thread_name_prefix
.
c_str
(),
_thread_name_prefix
.
empty
()
?
""
:
"/"
,
name_
?
"/"
:
""
,
name_
?
name_
:
""
);
#endif
nthreads_started
++
;
thread_
.
start
(
tfn_
,
arg_
,
namebuf
)
;
}
int
zmq
::
thread_ctx_t
::
set
(
int
option_
,
int
optval_
)
...
...
src/io_thread.cpp
View file @
be200896
...
...
@@ -56,8 +56,11 @@ zmq::io_thread_t::~io_thread_t ()
void
zmq
::
io_thread_t
::
start
()
{
char
name
[
16
];
snprintf
(
name
,
sizeof
(
name
),
"IO %u"
,
get_tid
()
-
zmq
::
ctx_t
::
reaper_tid
);
char
name
[
16
]
=
""
;
#ifndef ZMQ_HAVE_WINDOWS
snprintf
(
name
,
sizeof
(
name
),
"IO/%u"
,
get_tid
()
-
zmq
::
ctx_t
::
reaper_tid
-
1
);
#endif
// Start the underlying I/O thread.
_poller
->
start
(
name
);
}
...
...
src/thread.cpp
View file @
be200896
...
...
@@ -54,6 +54,7 @@ static unsigned int __stdcall thread_routine (void *arg_)
void
zmq
::
thread_t
::
start
(
thread_fn
*
tfn_
,
void
*
arg_
,
const
char
*
name_
)
{
LIBZMQ_UNUSED
(
name_
);
_tfn
=
tfn_
;
_arg
=
arg_
;
#if defined _WIN32_WCE
...
...
@@ -111,6 +112,7 @@ static void *thread_routine (void *arg_)
void
zmq
::
thread_t
::
start
(
thread_fn
*
tfn_
,
void
*
arg_
,
const
char
*
name_
)
{
LIBZMQ_UNUSED
(
name_
);
_tfn
=
tfn_
;
_arg
=
arg_
;
_descriptor
=
taskSpawn
(
NULL
,
DEFAULT_PRIORITY
,
DEFAULT_OPTIONS
,
...
...
@@ -179,7 +181,7 @@ static void *thread_routine (void *arg_)
#endif
zmq
::
thread_t
*
self
=
(
zmq
::
thread_t
*
)
arg_
;
self
->
applySchedulingParameters
();
pthread_setname_np
(
pthread_self
(),
self
->
_name
.
c_str
());
self
->
setThreadName
(
self
->
_name
.
c_str
());
self
->
_tfn
(
self
->
_arg
);
return
NULL
;
}
...
...
@@ -311,20 +313,25 @@ void zmq::thread_t::setThreadName (const char *name_)
if
(
!
name_
)
return
;
/* Fails with permission denied on Android 5/6 */
#if defined(ZMQ_HAVE_ANDROID)
return
;
#endif
#if defined(ZMQ_HAVE_PTHREAD_SETNAME_1)
int
rc
=
pthread_setname_np
(
name_
);
if
(
rc
)
return
;
#elif defined(ZMQ_HAVE_PTHREAD_SETNAME_2)
int
rc
=
pthread_setname_np
(
_descriptor
,
name_
);
int
rc
=
pthread_setname_np
(
pthread_self
()
,
name_
);
if
(
rc
)
return
;
#elif defined(ZMQ_HAVE_PTHREAD_SETNAME_3)
int
rc
=
pthread_setname_np
(
_descriptor
,
name_
,
NULL
);
int
rc
=
pthread_setname_np
(
pthread_self
()
,
name_
,
NULL
);
if
(
rc
)
return
;
#elif defined(ZMQ_HAVE_PTHREAD_SET_NAME)
pthread_set_name_np
(
_descriptor
,
name_
);
pthread_set_name_np
(
pthread_self
()
,
name_
);
#endif
}
...
...
src/thread.hpp
View file @
be200896
...
...
@@ -56,6 +56,7 @@ class thread_t
inline
thread_t
()
:
_tfn
(
NULL
),
_arg
(
NULL
),
_name
(
""
),
_started
(
false
),
_thread_priority
(
ZMQ_THREAD_PRIORITY_DFLT
),
_thread_sched_policy
(
ZMQ_THREAD_SCHED_POLICY_DFLT
)
...
...
@@ -73,7 +74,7 @@ class thread_t
// Creates OS thread. 'tfn' is main thread function. It'll be passed
// 'arg' as an argument.
void
start
(
thread_fn
*
tfn_
,
void
*
arg_
,
const
char
*
name_
=
"0MQ"
);
void
start
(
thread_fn
*
tfn_
,
void
*
arg_
,
const
char
*
name_
);
// Returns whether the thread was started, i.e. start was called.
bool
get_started
()
const
;
...
...
@@ -100,9 +101,7 @@ class thread_t
void
applySchedulingParameters
();
thread_fn
*
_tfn
;
void
*
_arg
;
#ifndef ZMQ_HAVE_WINDOWS
std
::
string
_name
;
#endif
private
:
bool
_started
;
...
...
src/zmq_utils.cpp
View file @
be200896
...
...
@@ -84,7 +84,7 @@ void *zmq_threadstart (zmq_thread_fn *func_, void *arg_)
{
zmq
::
thread_t
*
thread
=
new
(
std
::
nothrow
)
zmq
::
thread_t
;
alloc_assert
(
thread
);
thread
->
start
(
func_
,
arg_
);
thread
->
start
(
func_
,
arg_
,
"ZMQapp"
);
return
thread
;
}
...
...
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