Merge pull request #22 from MedicineYeh/master

Add thread name + include pthread in example.c
This commit is contained in:
Johan 2015-11-24 21:43:25 +00:00
commit c606e5ad4a
2 changed files with 6 additions and 0 deletions

View File

@ -12,6 +12,7 @@
* */
#include <stdio.h>
#include <pthread.h>
#include "thpool.h"

View File

@ -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;