schedule: make 'current' a private member of the scheduler
authorBrian Norris <banorris@uci.edu>
Thu, 15 Mar 2012 05:56:30 +0000 (22:56 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 15 Mar 2012 05:56:30 +0000 (22:56 -0700)
schedule.cc
schedule.h

index 687d30612d2e2c3549caf4e922210885fad94941..c02ca62b12a16cd1c07d58ffd20f1ac383b57181 100644 (file)
@@ -5,8 +5,6 @@
 #include "common.h"
 #include "model.h"
 
 #include "common.h"
 #include "model.h"
 
-struct thread *current;
-
 void DefaultScheduler::add_thread(struct thread *t)
 {
        DEBUG("thread %d\n", t->id);
 void DefaultScheduler::add_thread(struct thread *t)
 {
        DEBUG("thread %d\n", t->id);
@@ -15,17 +13,13 @@ void DefaultScheduler::add_thread(struct thread *t)
 
 struct thread *DefaultScheduler::next_thread(void)
 {
 
 struct thread *DefaultScheduler::next_thread(void)
 {
-       struct thread *t;
-
        if (queue.empty())
                return NULL;
 
        if (queue.empty())
                return NULL;
 
-       t = queue.front();
+       current = queue.front();
        queue.pop_front();
 
        queue.pop_front();
 
-       current = t;
-
-       return t;
+       return current;
 }
 
 struct thread *DefaultScheduler::get_current_thread(void)
 }
 
 struct thread *DefaultScheduler::get_current_thread(void)
index 762e16818ed220dfc3a313a0b297638d7e9bfddd..aa291ef8cd788872f14adce2f7199a6d3186f1de 100644 (file)
@@ -20,6 +20,7 @@ public:
        struct thread * get_current_thread(void);
 private:
        std::list<struct thread *> queue;
        struct thread * get_current_thread(void);
 private:
        std::list<struct thread *> queue;
+       struct thread *current;
 };
 
 #endif /* __SCHEDULE_H__ */
 };
 
 #endif /* __SCHEDULE_H__ */