From: Brian Norris Date: Tue, 11 Sep 2012 19:24:15 +0000 (-0700) Subject: model: replace action conditions with switch block X-Git-Tag: pldi2013~224 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f2a014110185c734180545ffc1dc2f0dcd30fd0c;p=model-checker.git model: replace action conditions with switch block --- diff --git a/model.cc b/model.cc index 90c7ad9..ba239b9 100644 --- a/model.cc +++ b/model.cc @@ -307,28 +307,37 @@ Thread * ModelChecker::check_current_action(ModelAction *curr) } } - /* Assign 'creation' parent */ - if (curr->get_type() == THREAD_CREATE) { + /* Thread specific actions */ + switch(curr->get_type()) { + case THREAD_CREATE: { Thread *th = (Thread *)curr->get_location(); th->set_creation(curr); - } else if (curr->get_type() == THREAD_JOIN) { + break; + } + case THREAD_JOIN: { Thread *wait, *join; wait = get_thread(curr->get_tid()); join = (Thread *)curr->get_location(); if (!join->is_complete()) scheduler->wait(wait, join); - } else if (curr->get_type() == THREAD_FINISH) { + break; + } + case THREAD_FINISH: { Thread *th = get_thread(curr->get_tid()); while (!th->wait_list_empty()) { Thread *wake = th->pop_wait_list(); scheduler->wake(wake); } th->complete(); + break; } - - /* Deal with new thread */ - if (curr->get_type() == THREAD_START) + case THREAD_START: { check_promises(NULL, curr->get_cv()); + break; + } + default: + break; + } /* Assign reads_from values */ Thread *th = get_thread(curr->get_tid());