mirror of https://git.kore.io/kore.git
Let tasks only start after kore_task_run() is called.
This commit is contained in:
parent
ed1e5e249e
commit
fff0a763ae
|
@ -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
|
||||
|
|
|
@ -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 *);
|
||||
|
|
Loading…
Reference in New Issue