]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - sched.c
sched: Do not shadow task_info in struct task.
[paraslash.git] / sched.c
diff --git a/sched.c b/sched.c
index 0a1cff28521dfe12c8f75316b1a1ce35206c1918..1280e07e1040d475281d554ee8911c7afe8de613 100644 (file)
--- a/sched.c
+++ b/sched.c
 #include "error.h"
 
 struct task {
-       /** The task name supplied when the task was registered(). */
+       /** A copy of the task name supplied when the task was registered. */
        char *name;
-       /** Copied from the task_info struct during task_register(). */
-       void (*pre_select)(struct sched *s, struct task *t);
-       /** Copied from the task_info struct during task_register(). */
-       int (*post_select)(struct sched *s, struct task *t);
+       /** Copied during task_register(). */
+       struct task_info info;
        /** Whether this task is active (>=0) or in error state (<0). */
        int status;
        /** Position of the task in the task list of the scheduler. */
@@ -33,8 +31,6 @@ struct task {
        int notification;
        /** True if task is in error state and exit status has been queried. */
        bool dead;
-       /** Usually a pointer to the struct containing this task. */
-       void *context;
 };
 
 static struct timeval now_struct;
@@ -55,8 +51,8 @@ static void sched_preselect(struct sched *s)
                        continue;
                if (t->notification != 0)
                        sched_min_delay(s);
-               if (t->pre_select)
-                       t->pre_select(s, t);
+               if (t->info.pre_select)
+                       t->info.pre_select(s, t);
        }
 }
 
@@ -72,13 +68,13 @@ static void unlink_and_free_task(struct task *t)
 static inline void call_post_select(struct sched *s, struct task *t)
 {
 #ifndef SCHED_DEBUG
-       t->status = t->post_select(s, t);
+       t->status = t->info.post_select(s, t);
 #else
        struct timeval t1, t2, diff;
        unsigned long pst;
 
        clock_get_realtime(&t1);
-       t->status = t->post_select(s, t);
+       t->status = t->info.post_select(s, t);
        clock_get_realtime(&t2);
        tv_diff(&t1, &t2, &diff);
        pst = tv2ms(&diff);
@@ -240,13 +236,11 @@ struct task *task_register(struct task_info *info, struct sched *s)
        if (!s->task_list.next)
                INIT_LIST_HEAD(&s->task_list);
 
+       t->info = *info;
        t->name = para_strdup(info->name);
        t->notification = 0;
        t->status = 0;
        t->dead = false;
-       t->pre_select = info->pre_select;
-       t->post_select = info->post_select;
-       t->context = info->context;
        list_add_tail(&t->node, &s->task_list);
        return t;
 }
@@ -261,7 +255,7 @@ struct task *task_register(struct task_info *info, struct sched *s)
  */
 void *task_context(struct task *t)
 {
-       return t->context;
+       return t->info.context;
 }
 
 /**