runqueue: add a function that allows adding jobs to the front of the runqueue
Signed-off-by: John Crispin <blogic@openwrt.org>
This commit is contained in:
parent
a34c8f6918
commit
bc8167eb99
4 changed files with 23 additions and 2 deletions
15
runqueue.c
15
runqueue.c
|
@ -145,7 +145,7 @@ __runqueue_task_timeout(struct uloop_timeout *timeout)
|
||||||
runqueue_task_cancel(t, t->cancel_type);
|
runqueue_task_cancel(t, t->cancel_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void runqueue_task_add(struct runqueue *q, struct runqueue_task *t, bool running)
|
static void _runqueue_task_add(struct runqueue *q, struct runqueue_task *t, bool running, bool first)
|
||||||
{
|
{
|
||||||
struct safe_list *head;
|
struct safe_list *head;
|
||||||
|
|
||||||
|
@ -166,6 +166,9 @@ void runqueue_task_add(struct runqueue *q, struct runqueue_task *t, bool running
|
||||||
|
|
||||||
t->timeout.cb = __runqueue_task_timeout;
|
t->timeout.cb = __runqueue_task_timeout;
|
||||||
t->q = q;
|
t->q = q;
|
||||||
|
if (first)
|
||||||
|
safe_list_add_first(&t->list, head);
|
||||||
|
else
|
||||||
safe_list_add(&t->list, head);
|
safe_list_add(&t->list, head);
|
||||||
t->cancelled = false;
|
t->cancelled = false;
|
||||||
t->queued = true;
|
t->queued = true;
|
||||||
|
@ -175,6 +178,16 @@ void runqueue_task_add(struct runqueue *q, struct runqueue_task *t, bool running
|
||||||
runqueue_start_next(q);
|
runqueue_start_next(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void runqueue_task_add(struct runqueue *q, struct runqueue_task *t, bool running)
|
||||||
|
{
|
||||||
|
_runqueue_task_add(q, t, running, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void runqueue_task_add_first(struct runqueue *q, struct runqueue_task *t, bool running)
|
||||||
|
{
|
||||||
|
_runqueue_task_add(q, t, running, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void runqueue_task_kill(struct runqueue_task *t)
|
void runqueue_task_kill(struct runqueue_task *t)
|
||||||
{
|
{
|
||||||
struct runqueue *q = t->q;
|
struct runqueue *q = t->q;
|
||||||
|
|
|
@ -100,6 +100,7 @@ void runqueue_stop(struct runqueue *q);
|
||||||
void runqueue_resume(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(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_complete(struct runqueue_task *t);
|
||||||
|
|
||||||
void runqueue_task_cancel(struct runqueue_task *t, int type);
|
void runqueue_task_cancel(struct runqueue_task *t, int type);
|
||||||
|
|
|
@ -86,6 +86,12 @@ void safe_list_add(struct safe_list *list, struct safe_list *head)
|
||||||
list_add_tail(&list->list, &head->list);
|
list_add_tail(&list->list, &head->list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void safe_list_add_first(struct safe_list *list, struct safe_list *head)
|
||||||
|
{
|
||||||
|
list->i = NULL;
|
||||||
|
list_add(&list->list, &head->list);
|
||||||
|
}
|
||||||
|
|
||||||
void safe_list_del(struct safe_list *list)
|
void safe_list_del(struct safe_list *list)
|
||||||
{
|
{
|
||||||
struct safe_list_iterator *i, *next_i, **tail;
|
struct safe_list_iterator *i, *next_i, **tail;
|
||||||
|
|
|
@ -42,6 +42,7 @@ int safe_list_for_each(struct safe_list *list,
|
||||||
void *ctx);
|
void *ctx);
|
||||||
|
|
||||||
void safe_list_add(struct safe_list *list, struct safe_list *head);
|
void safe_list_add(struct safe_list *list, struct safe_list *head);
|
||||||
|
void safe_list_add_first(struct safe_list *list, struct safe_list *head);
|
||||||
void safe_list_del(struct safe_list *list);
|
void safe_list_del(struct safe_list *list);
|
||||||
|
|
||||||
#define INIT_SAFE_LIST(_head) \
|
#define INIT_SAFE_LIST(_head) \
|
||||||
|
|
Loading…
Reference in a new issue