From b2e1861247c00af280dafdfd79e855f0011dee2d Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 23 Apr 2012 15:39:07 -0700 Subject: [PATCH] schedule: refactor next_thread() for better debug printing 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. --- schedule.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/schedule.cc b/schedule.cc index 2498347..4d1cb12 100644 --- a/schedule.cc +++ b/schedule.cc @@ -13,19 +13,19 @@ Thread *Scheduler::next_thread(void) { 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) -- 2.34.1