Smallers steps to keep plugin running
[oweals/gnunet.git] / src / include / gnunet_scheduler_lib.h
index 16fd2e807db78ff0ef162f75165918f77fa9baaf..b39feb9268b108aadc1a223270912eddc7d0889b 100644 (file)
@@ -141,11 +141,21 @@ enum GNUNET_SCHEDULER_Priority
    */
   GNUNET_SCHEDULER_PRIORITY_URGENT = 6,
 
+  /**
+   * This is an internal priority level that is only used for tasks
+   * that are being triggered due to shutdown (they have automatically
+   * highest priority).  User code must not use this priority level
+   * directly.  Tasks run with this priority level that internally
+   * schedule other tasks will see their original priority level
+   * be inherited (unless otherwise specified).
+   */
+  GNUNET_SCHEDULER_PRIORITY_SHUTDOWN = 7,
+
   /**
    * Number of priorities (must be the last priority).
    * This priority must not be used by clients.
    */
-  GNUNET_SCHEDULER_PRIORITY_COUNT = 7
+  GNUNET_SCHEDULER_PRIORITY_COUNT = 8
 };
 
 #include "gnunet_time_lib.h"
@@ -271,14 +281,14 @@ void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
  * and the reason code can be specified.
  *
  * @param sched scheduler to use
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @param reason reason for task invocation
  */
 void
 GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
-                                   GNUNET_SCHEDULER_Task main,
-                                   void *cls,
+                                   GNUNET_SCHEDULER_Task task,
+                                   void *task_cls,
                                    enum GNUNET_SCHEDULER_Reason reason);
 
 
@@ -290,7 +300,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
  * @param sched scheduler to use
  * @param prerequisite_task run this task after the task with the given
  *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
+ *        conditions, such as delay, read or write-readiness
  *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
  *        on completion of other tasks (this will cause the task to run as
  *        soon as possible).
@@ -323,6 +333,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
@@ -457,14 +483,14 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
  * && (delay-ready
  *     || any-rs-ready
  *     || any-ws-ready
- *     || (shutdown-active && run-on-shutdown) )
+ *     || shutdown-active)
  * </code>
  *
  * @param sched scheduler to use
  * @param prio how important is this task?
  * @param prerequisite_task run this task after the task with the given
  *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
+ *        conditions, such as delay, read or write-readiness
  *        are satisfied).  Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
  *        on completion of other tasks.
  * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever",