I'll need random access to its elements later.
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;
}
#ifndef __SCHEDULE_H__
#define __SCHEDULE_H__
-#include <queue>
+#include <list>
#include "threads.h"
#include "model.h"
Thread * next_thread(void);
Thread * get_current_thread(void);
private:
- std::queue<Thread *> queue;
+ std::list<Thread *> readyList;
Thread *current;
};