It makes more sense to call print() at the end of the the next_thread()
routine, to see consistent printing for all cases. So I refactor the control
flow to a single return statement.
{
Thread *t = model->schedule_next_thread();
- print();
-
if (t != NULL) {
readyList.remove(t);
- return t;
+ } else if (readyList.empty()) {
+ t = NULL;
+ } else {
+ t = readyList.front();
+ current = t;
+ readyList.pop_front();
}
- if (readyList.empty())
- return NULL;
- current = readyList.front();
- readyList.pop_front();
+ print();
- return current;
+ return t;
}
Thread *Scheduler::get_current_thread(void)