Lines Matching defs:task
49 struct threadpool_task *task;
58 /* Pull the first task from the list. We don't free it -- it now lacks
62 task = pool->workqueue;
63 pool->workqueue = task->next;
65 /* Call the task's work func. */
67 task->work(task->data);
69 task->finished = TRUE;
70 pthread_cond_broadcast(&task->finish);
145 struct threadpool_task *task, *previous;
152 task = calloc(1, sizeof(*task));
153 if (!task) {
158 task->work = work;
159 task->data = data;
160 task->next = NULL;
161 pthread_cond_init(&task->finish, NULL);
166 pool->workqueue = task;
172 previous->next = task;
177 return task;
181 * Blocks on the completion of the given task and frees the task.
187 struct threadpool_task *task = *task_handle;
189 if (!pool || !task)
193 while (!task->finished)
194 pthread_cond_wait(&task->finish, &pool->m);
197 pthread_cond_destroy(&task->finish);
198 free(task);