From: Brian Norris Date: Fri, 20 Apr 2012 17:30:58 +0000 (-0700) Subject: schedule: replace queue with list X-Git-Tag: pldi2013~532 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f6c3c97520fa724c97c6a04eb8da4bf8a4bb2477;p=model-checker.git schedule: replace queue with list I'll need random access to its elements later. --- diff --git a/schedule.cc b/schedule.cc index 691c6f4..0432825 100644 --- a/schedule.cc +++ b/schedule.cc @@ -6,16 +6,16 @@ void Scheduler::add_thread(Thread *t) { DEBUG("thread %d\n", t->get_id()); - queue.push(t); + readyList.push_back(t); } Thread *Scheduler::next_thread(void) { - if (queue.empty()) + if (readyList.empty()) return NULL; - current = queue.front(); - queue.pop(); + current = readyList.front(); + readyList.pop_front(); return current; } diff --git a/schedule.h b/schedule.h index 64531b5..aa50ac3 100644 --- a/schedule.h +++ b/schedule.h @@ -1,7 +1,7 @@ #ifndef __SCHEDULE_H__ #define __SCHEDULE_H__ -#include +#include #include "threads.h" #include "model.h" @@ -12,7 +12,7 @@ public: Thread * next_thread(void); Thread * get_current_thread(void); private: - std::queue queue; + std::list readyList; Thread *current; };