Add work to the thread pool */
| 170 | |
| 171 | /* Add work to the thread pool */ |
| 172 | int thpool_add_work(thpool_* thpool_p, void (*function_p)(void *), void *arg_p) { |
| 173 | job *newjob; |
| 174 | |
| 175 | newjob = (struct job *)rm_calloc(1, sizeof(struct job)); |
| 176 | if(newjob == NULL) { |
| 177 | err("thpool_add_work(): Could not allocate memory for new job\n"); |
| 178 | return -1; |
| 179 | } |
| 180 | |
| 181 | /* add function and argument */ |
| 182 | newjob->function = function_p; |
| 183 | newjob->arg = arg_p; |
| 184 | |
| 185 | /* add job to queue */ |
| 186 | jobqueue_push(&thpool_p->jobqueue, newjob); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | /* Wait until all jobs have finished */ |
| 192 | void thpool_wait(thpool_* thpool_p) { |
no test coverage detected