From 70de2534e40ac0768f0f0d62a2b9d7bc593fba82 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 13 Nov 2009 11:38:19 +0000 Subject: [PATCH] add now --- src/include/gnunet_scheduler_lib.h | 16 ++++++++++++++++ src/util/scheduler.c | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index 16fd2e807..283d46dab 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h @@ -323,6 +323,22 @@ GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched, void *task_cls); +/** + * Schedule a new task to be run as soon as possible. The task + * will be run with the priority of the calling task. + * + * @param sched scheduler to use + * @param task main function of the task + * @param task_cls closure of task + * @return unique task identifier for the job + * only valid until "task" is started! + */ +GNUNET_SCHEDULER_TaskIdentifier +GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, + GNUNET_SCHEDULER_Task task, + void *task_cls); + + /** * Schedule a new task to be run with a specified delay. The task * will be scheduled for execution once the delay has expired. It diff --git a/src/util/scheduler.c b/src/util/scheduler.c index ee4a9a4f3..1df907a20 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -832,6 +832,31 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, } + +/** + * Schedule a new task to be run as soon as possible. The task + * will be run with the priority of the calling task. + * + * @param sched scheduler to use + * @param task main function of the task + * @param task_cls closure of task + * @return unique task identifier for the job + * only valid until "task" is started! + */ +GNUNET_SCHEDULER_TaskIdentifier +GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, + GNUNET_SCHEDULER_Task task, + void *task_cls) +{ + return GNUNET_SCHEDULER_add_select (sched, + GNUNET_SCHEDULER_PRIORITY_KEEP, + GNUNET_SCHEDULER_NO_TASK, + GNUNET_TIME_UNIT_ZERO, + NULL, NULL, task, task_cls); +} + + + /** * Schedule a new task to be run with a specified delay or when the * specified file descriptor is ready for reading. The delay can be -- 2.25.1