X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=runqueue.h;h=9728c9c5c86ba3a0af4277965479660d7e8f4eb9;hb=df5b7147f47ae3bca23bde18f3d432f5ce26a2ff;hp=127085f97b517688f32c5683a11e9a6ad427001f;hpb=92fdad5448cda86a2e0fc4a0d3ff8843d6435e11;p=project%2Flibubox.git diff --git a/runqueue.h b/runqueue.h index 127085f..9728c9c 100644 --- a/runqueue.h +++ b/runqueue.h @@ -56,14 +56,14 @@ struct runqueue_task_type { * called to request cancelling a task * * int type is used as an optional hint for the method to be used when - * cancelling the task, e.g. a signal number for processes. Calls - * runqueue_task_complete when done. + * cancelling the task, e.g. a signal number for processes. The cancel + * callback should call runqueue_task_complete when done. */ void (*cancel)(struct runqueue *q, struct runqueue_task *t, int type); /* * called to kill a task. must not make any calls to runqueue_task_complete, - * it has already been removed from the list. + * which will be called after this returns. */ void (*kill)(struct runqueue *q, struct runqueue_task *t); }; @@ -73,6 +73,8 @@ struct runqueue_task { 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; @@ -86,9 +88,17 @@ struct runqueue_task { struct runqueue_process { struct runqueue_task task; struct uloop_process proc; - void (*complete)(struct runqueue *q, struct runqueue_process *p, int ret); }; +#define RUNQUEUE_INIT(_name, _max_running) { \ + .tasks_active = SAFE_LIST_INIT(_name.tasks_active), \ + .tasks_inactive = SAFE_LIST_INIT(_name.tasks_inactive), \ + .max_running_tasks = _max_running \ + } + +#define RUNQUEUE(_name, _max_running) \ + struct runqueue _name = RUNQUEUE_INIT(_name, _max_running) + void runqueue_init(struct runqueue *q); void runqueue_cancel(struct runqueue *q); void runqueue_cancel_active(struct runqueue *q); @@ -99,6 +109,7 @@ void runqueue_stop(struct runqueue *q); void runqueue_resume(struct runqueue *q); void runqueue_task_add(struct runqueue *q, struct runqueue_task *t, bool running); +void runqueue_task_add_first(struct runqueue *q, struct runqueue_task *t, bool running); void runqueue_task_complete(struct runqueue_task *t); void runqueue_task_cancel(struct runqueue_task *t, int type);