Merge branch 't/sync'
[paraslash.git] / sched.h
diff --git a/sched.h b/sched.h
index ea9578f7b05b3bae17e69e87543675e902d0c590..234a8458d5870a1f14c66c81c140b61c0c20bf01 100644 (file)
--- a/sched.h
+++ b/sched.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2011 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2013 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -29,6 +29,10 @@ struct sched {
        int max_fileno;
        /** If non-NULL, use this function instead of para_select. */
        int (*select_function)(int, fd_set *, fd_set *, struct timeval *);
+       /** Currently active pre_select functions. */
+       struct list_head pre_select_list;
+       /** Currently active post_select functions. */
+       struct list_head post_select_list;
 };
 
 /**
@@ -37,10 +41,7 @@ struct sched {
  * Before registering a task to the scheduler, the task structure must be
  * filled in properly by the caller.
  *
- * If one of these functions sets \a t->error to a negative value, the
- * task gets unregistered automatically.
- *
- * \sa struct sched.
+ * \sa \ref sched.
  */
 struct task {
        /**
@@ -51,11 +52,13 @@ struct task {
         */
        void (*pre_select)(struct sched *s, struct task *t);
        /**
-        * The postselect hook of \a t.
+        * The post select hook of \a t.
         *
-        * Evaluate and act upon the results of the previous select call.
+        * Its purpose is to evaluate and act upon the results of the previous
+        * select call. If this function returns a negative value, the
+        * scheduler unregisters the task.
         */
-       void (*post_select)(struct sched *s, struct task *t);
+       int (*post_select)(struct sched *s, struct task *t);
        /** Whether this task is in error state. */
        int error;
        /** Position of the task in the pre_select list of the scheduler. */
@@ -64,20 +67,24 @@ struct task {
        struct list_head post_select_node;
        /** Descriptive text and current status of the task. */
        char status[255];
+       /** If less than zero, the task was notified by another task. */
+       int notification;
 };
 
 /**
  * This is set by the scheduler at the beginning of its main loop.  It may be
  * used (read-only) from everywhere. As none of the functions called by the
  * scheduler are allowed to block, this value should be accurate enough so that
- * there is no need to call gettimeofday() directly.
+ * there is no need to call clock_gettime() directly.
  */
 extern struct timeval *now;
 
-void register_task(struct task *t);
+void register_task(struct sched *s, struct task *t);
 int schedule(struct sched *s);
-char *get_task_list(void);
-void sched_shutdown(void);
+char *get_task_list(struct sched *s);
+void task_notify(struct task *t, int err);
+void task_notify_all(struct sched *s, int err);
+int task_get_notification(struct task *t);
 void sched_min_delay(struct sched *s);
 void sched_request_timeout(struct timeval *to, struct sched *s);
 void sched_request_timeout_ms(long unsigned ms, struct sched *s);