Let tasks only start after kore_task_run() is called.

This commit is contained in:
Joris Vink 2014-06-30 14:35:32 +02:00
parent ed1e5e249e
commit fff0a763ae
2 changed files with 10 additions and 4 deletions

View File

@ -58,7 +58,6 @@ void
kore_task_create(struct kore_task **out, int (*entry)(struct kore_task *))
{
struct kore_task *t;
struct kore_task_thread *tt;
t = kore_malloc(sizeof(struct kore_task));
@ -70,6 +69,15 @@ kore_task_create(struct kore_task **out, int (*entry)(struct kore_task *))
if (socketpair(AF_UNIX, SOCK_STREAM, 0,t->fds) == -1)
fatal("kore_task_create: socketpair() %s", errno_s);
if (out != NULL)
*out = t;
}
void
kore_task_run(struct kore_task *t)
{
struct kore_task_thread *tt;
pthread_mutex_lock(&task_thread_lock);
if (TAILQ_EMPTY(&task_threads))
task_thread_spawn(&tt);
@ -84,9 +92,6 @@ kore_task_create(struct kore_task **out, int (*entry)(struct kore_task *))
pthread_mutex_unlock(&(tt->lock));
pthread_cond_signal(&(tt->cond));
if (out != NULL)
*out = t;
}
void

View File

@ -47,6 +47,7 @@ struct kore_task_thread {
};
void kore_task_init(void);
void kore_task_run(struct kore_task *);
void kore_task_finish(struct kore_task *);
void kore_task_destroy(struct kore_task *);
int kore_task_finished(struct kore_task *);