commit fff0a763aec09d11c7b5b1aa82f7dc1dfd234997
parent ed1e5e249e5ca382c04809f79701412dd9f7aeba
Author: Joris Vink <joris@coders.se>
Date: Mon, 30 Jun 2014 14:35:32 +0200
Let tasks only start after kore_task_run() is called.
Diffstat:
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/contrib/tasks/kore_tasks.c b/contrib/tasks/kore_tasks.c
@@ -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
diff --git a/includes/kore_tasks.h b/includes/kore_tasks.h
@@ -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 *);