From f6c3c97520fa724c97c6a04eb8da4bf8a4bb2477 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 20 Apr 2012 10:30:58 -0700 Subject: [PATCH] schedule: replace queue with list I'll need random access to its elements later. --- schedule.cc | 8 ++++---- schedule.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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; }; -- 2.34.1