runqueue_process_cancel_cb(q, t, type);
}
-static void q_sleep_complete(struct runqueue *q, struct runqueue_process *p, int ret)
+static void q_sleep_complete(struct runqueue *q, struct runqueue_task *p)
{
- struct sleeper *s = container_of(p, struct sleeper, proc);
+ struct sleeper *s = container_of(p, struct sleeper, proc.task);
fprintf(stderr, "[%d/%d] finish 'sleep %d'\n", q->running_tasks, q->max_running_tasks, s->val);
free(s);
s = calloc(1, sizeof(*s));
s->proc.task.type = &sleeper_type;
s->proc.task.run_timeout = 500;
- s->proc.complete = q_sleep_complete;
+ s->proc.task.complete = q_sleep_complete;
s->val = val;
runqueue_task_add(&q, &s->proc.task, false);
}
runqueue_task_complete(t);
if (running && t->type->kill)
t->type->kill(q, t);
+ if (t->complete)
+ t->complete(q, t);
runqueue_start_next(q);
}
__runqueue_proc_cb(struct uloop_process *p, int ret)
{
struct runqueue_process *t = container_of(p, struct runqueue_process, proc);
- struct runqueue *q = t->task.q;
runqueue_task_complete(&t->task);
- if (t->complete)
- t->complete(q, t, ret);
}
void runqueue_process_cancel_cb(struct runqueue *q, struct runqueue_task *t, int type)
uloop_process_delete(&p->proc);
kill(p->proc.pid, SIGKILL);
- __runqueue_proc_cb(&p->proc, -1);
}
static const struct runqueue_task_type runqueue_proc_type = {
const struct runqueue_task_type *type;
struct runqueue *q;
+ void (*complete)(struct runqueue *q, struct runqueue_task *t);
+
struct uloop_timeout timeout;
int run_timeout;
int cancel_timeout;
struct runqueue_process {
struct runqueue_task task;
struct uloop_process proc;
- void (*complete)(struct runqueue *q, struct runqueue_process *p, int ret);
};
void runqueue_init(struct runqueue *q);