mirror of
https://github.com/Pithikos/C-Thread-Pool
synced 2024-11-22 05:31:18 +03:00
add thread name, fix warning in the example
thread name is good for both profiling and debuging also htop can turn on the option 'Show custom thread names' in 'Display options' the warning in example is ‘pthread_self’ [-Wimplicit-function-declaration]
This commit is contained in:
parent
ab2c0bb8ad
commit
90c4561942
@ -12,6 +12,7 @@
|
||||
* */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include "thpool.h"
|
||||
|
||||
|
||||
|
5
thpool.c
5
thpool.c
@ -16,6 +16,7 @@
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "thpool.h"
|
||||
|
||||
@ -335,6 +336,10 @@ static void thread_hold () {
|
||||
* @return nothing
|
||||
*/
|
||||
static void* thread_do(struct thread* thread_p){
|
||||
/* Set thread name for profiling and debuging */
|
||||
char thread_name[128] = {0};
|
||||
sprintf(thread_name, "thread-pool-%d", thread_p->id);
|
||||
prctl(PR_SET_NAME, thread_name);
|
||||
|
||||
/* Assure all threads have been created before starting serving */
|
||||
thpool_* thpool_p = thread_p->thpool_p;
|
||||
|
Loading…
Reference in New Issue
Block a user