Initialize a thread in the thread pool * * @param thread address to the pointer of the thread to be created * @param id id to be given to the thread * @return 0 on success, -1 otherwise. */
| 357 | * @return 0 on success, -1 otherwise. |
| 358 | */ |
| 359 | static int thread_init(thpool_* thpool_p, struct thread **thread_p, int id) { |
| 360 | |
| 361 | *thread_p = (struct thread *)rm_calloc(1, sizeof(struct thread)); |
| 362 | if(thread_p == NULL) { |
| 363 | err("thread_init(): Could not allocate memory for thread\n"); |
| 364 | return -1; |
| 365 | } |
| 366 | |
| 367 | (*thread_p)->thpool_p = thpool_p; |
| 368 | (*thread_p)->id = id; |
| 369 | |
| 370 | pthread_create(&(*thread_p)->pthread, NULL, (void *)thread_do, (*thread_p)); |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | /* Sets the calling thread on hold */ |
| 375 | static void thread_hold(int sig_id) { |
no test coverage detected