From: Brian Norris Date: Mon, 23 Apr 2012 22:39:07 +0000 (-0700) Subject: schedule: refactor next_thread() for better debug printing X-Git-Tag: pldi2013~523 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b2e1861247c00af280dafdfd79e855f0011dee2d;p=model-checker.git 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. --- 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)