X-Git-Url: http://git.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=runqueue.h;h=9728c9c5c86ba3a0af4277965479660d7e8f4eb9;hp=00ad1ebf859e0286594659928629359c3b3e7993;hb=870acee325fe61267ac4ec1f0c6cba80b954cce5;hpb=c4b79e4b5448abcd04c1848e212a237e8b17c3de diff --git a/runqueue.h b/runqueue.h index 00ad1eb..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); }; @@ -90,6 +90,15 @@ struct runqueue_process { struct uloop_process proc; }; +#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); @@ -100,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);