mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-30 13:47:13 +01:00
Problem: Threads don't have names which complicates debugging.
Solution: 1. Use optional name parameter in thread_t::start for operating systems that have thread names. 2. Give start_thread() an optional name parameter for the thread's name. If this parameter is set, it will be appended to "0MQ:". If not set, "0MQ" will be used as the thread's name. 3. Give epoll the ability to name its thread. Then use this in io_thread and reaper to name them.
This commit is contained in:
committed by
Luca Boccassi
parent
c47b2af90a
commit
484374f2b6
@@ -52,7 +52,7 @@ static unsigned int __stdcall thread_routine (void *arg_)
|
||||
}
|
||||
}
|
||||
|
||||
void zmq::thread_t::start (thread_fn *tfn_, void *arg_)
|
||||
void zmq::thread_t::start (thread_fn *tfn_, void *arg_, const char *name_)
|
||||
{
|
||||
_tfn = tfn_;
|
||||
_arg = arg_;
|
||||
@@ -109,7 +109,7 @@ static void *thread_routine (void *arg_)
|
||||
}
|
||||
}
|
||||
|
||||
void zmq::thread_t::start (thread_fn *tfn_, void *arg_)
|
||||
void zmq::thread_t::start (thread_fn *tfn_, void *arg_, const char *name_)
|
||||
{
|
||||
_tfn = tfn_;
|
||||
_arg = arg_;
|
||||
@@ -179,15 +179,17 @@ 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->_tfn (self->_arg);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void zmq::thread_t::start (thread_fn *tfn_, void *arg_)
|
||||
void zmq::thread_t::start (thread_fn *tfn_, void *arg_, const char *name_)
|
||||
{
|
||||
_tfn = tfn_;
|
||||
_arg = arg_;
|
||||
_name = name_;
|
||||
int rc = pthread_create (&_descriptor, NULL, thread_routine, this);
|
||||
posix_assert (rc);
|
||||
_started = true;
|
||||
|
||||
Reference in New Issue
Block a user