/**
- * Request the shutdown of a scheduler. Marks all tasks
+ * Request the shutdown of a scheduler. Marks all tasks
* awaiting shutdown as ready. Note that tasks
* scheduled with #GNUNET_SCHEDULER_add_shutdown() AFTER this call
* will be delayed until the next shutdown signal.
* will be scheduled for execution once the delay has expired. It
* will be run with the DEFAULT priority.
*
- * @param delay when should this operation time out?
+ * @param delay with which the operation should be run
* @param task main function of the task
* @param task_cls closure of @a task
* @return unique task identifier for the job
void *task_cls);
+/**
+ * Schedule a new task to be run at the specified time. The task
+ * will be scheduled for execution once specified time has been
+ * reached. It will be run with the DEFAULT priority.
+ *
+ * @param at time at which this operation should run
+ * @param task main function of the task
+ * @param task_cls closure of @a task
+ * @return unique task identifier for the job
+ * only valid until @a task is started!
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at,
+ GNUNET_SCHEDULER_TaskCallback 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.
*
- * @param delay when should this operation time out?
+ * @param delay when should this operation time out?
* @param priority priority to use for the task
* @param task main function of the task
* @param task_cls closure of @a task
void *task_cls);
+/**
+ * Schedule a new task to be run at the specified time. The task
+ * will be scheduled for execution at time @a at.
+ *
+ * @param at time when the operation should run
+ * @param priority priority to use for the task
+ * @param task main function of the task
+ * @param task_cls closure of @a task
+ * @return unique task identifier for the job
+ * only valid until @a task is started!
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at,
+ enum GNUNET_SCHEDULER_Priority priority,
+ GNUNET_SCHEDULER_TaskCallback task,
+ void *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
* scheduled for execution once either the delay has expired or the
* socket operation is ready.
*
- * @param delay when should this operation time out?
+ * @param delay when should this operation time out?
* @param priority priority of the task
* @param fd file-descriptor
* @param on_read whether to poll the file-descriptor for readability
* </code>
*
* @param prio how important is this task?
- * @param delay how long should we wait?
+ * @param delay how long should we wait?
* @param rs set of file descriptors we want to read (can be NULL)
* @param ws set of file descriptors we want to write (can be NULL)
* @param task main function of the task
* Is this task run on shutdown?
*/
int on_shutdown;
-
+
/**
* Is this task in the ready list?
*/
/**
- * Request the shutdown of a scheduler. Marks all tasks
+ * Request the shutdown of a scheduler. Marks all tasks
* awaiting shutdown as ready. Note that tasks
* scheduled with #GNUNET_SCHEDULER_add_shutdown() AFTER this call
* will be delayed until the next shutdown signal.
* Output stack trace of task @a t.
*
* @param t task to dump stack trace of
- */
+ */
static void
dump_backtrace (struct GNUNET_SCHEDULER_Task *t)
{
#if EXECINFO
unsigned int i;
-
+
for (i = 0; i < t->num_backtrace_strings; i++)
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Task %p trace %u: %s\n",
/**
- * Schedule a new task to be run with a specified delay. The task
- * will be scheduled for execution once the delay has expired.
+ * Schedule a new task to be run at the specified time. The task
+ * will be scheduled for execution at time @a at.
*
- * @param delay when should this operation time out?
+ * @param at time when the operation should run
* @param priority priority to use for the task
* @param task main function of the task
* @param task_cls closure of @a task
* only valid until @a task is started!
*/
struct GNUNET_SCHEDULER_Task *
-GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
- enum GNUNET_SCHEDULER_Priority priority,
- GNUNET_SCHEDULER_TaskCallback task,
- void *task_cls)
+GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at,
+ enum GNUNET_SCHEDULER_Priority priority,
+ GNUNET_SCHEDULER_TaskCallback task,
+ void *task_cls)
{
struct GNUNET_SCHEDULER_Task *t;
struct GNUNET_SCHEDULER_Task *pos;
#if PROFILE_DELAYS
t->start_time = GNUNET_TIME_absolute_get ();
#endif
- t->timeout = GNUNET_TIME_relative_to_absolute (delay);
+ t->timeout = at;
t->priority = priority;
t->lifeness = current_lifeness;
/* try tail first (optimization in case we are
* appending to a long list of tasks with timeouts) */
- if (0 == delay.rel_value_us)
+ if ( (NULL == pending_timeout_head) ||
+ (at.abs_value_us < pending_timeout_head->timeout.abs_value_us) )
{
GNUNET_CONTAINER_DLL_insert (pending_timeout_head,
pending_timeout_tail,
pending_timeout_tail,
prev,
t);
- /* finally, update heuristic insertion point to last insertion... */
- pending_timeout_last = t;
}
+ /* finally, update heuristic insertion point to last insertion... */
+ pending_timeout_last = t;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding task: %p\n",
}
+/**
+ * Schedule a new task to be run with a specified delay. The task
+ * will be scheduled for execution once the delay has expired.
+ *
+ * @param delay when should this operation time out?
+ * @param priority priority to use for the task
+ * @param task main function of the task
+ * @param task_cls closure of @a task
+ * @return unique task identifier for the job
+ * only valid until @a task is started!
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
+ enum GNUNET_SCHEDULER_Priority priority,
+ GNUNET_SCHEDULER_TaskCallback task,
+ void *task_cls)
+{
+ return GNUNET_SCHEDULER_add_at_with_priority (GNUNET_TIME_relative_to_absolute (delay),
+ priority,
+ task,
+ task_cls);
+}
+
+
/**
* Schedule a new task to be run with a specified priority.
*
}
+/**
+ * Schedule a new task to be run at the specified time. The task
+ * will be scheduled for execution once specified time has been
+ * reached. It will be run with the DEFAULT priority.
+ *
+ * @param at time at which this operation should run
+ * @param task main function of the task
+ * @param task_cls closure of @a task
+ * @return unique task identifier for the job
+ * only valid until @a task is started!
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at,
+ GNUNET_SCHEDULER_TaskCallback task,
+ void *task_cls)
+{
+ return GNUNET_SCHEDULER_add_at_with_priority (at,
+ GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ task,
+ 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
{
return GNUNET_SCHEDULER_add_delayed_with_priority (delay,
GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- task, task_cls);
+ task,
+ task_cls);
}
* scheduled for execution once either the delay has expired or the
* socket operation is ready. It will be run with the DEFAULT priority.
*
- * @param delay when should this operation time out?
+ * @param delay when should this operation time out?
* @param rfd read file-descriptor
* @param task main function of the task
* @param task_cls closure of @a task
* </code>
*
* @param prio how important is this task?
- * @param delay how long should we wait?
+ * @param delay how long should we wait?
* @param rs set of file descriptors we want to read (can be NULL)
* @param ws set of file descriptors we want to write (can be NULL)
* @param task main function of the task