projects
/
model-checker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dae59b7
)
model: replace action conditions with switch block
author
Brian Norris
<banorris@uci.edu>
Tue, 11 Sep 2012 19:24:15 +0000
(12:24 -0700)
committer
Brian Norris
<banorris@uci.edu>
Tue, 11 Sep 2012 19:26:27 +0000
(12:26 -0700)
model.cc
patch
|
blob
|
history
diff --git
a/model.cc
b/model.cc
index 90c7ad91493bf50bd0c7859ba1d01db7d12afb09..ba239b913b41a02ff401380ef65dfe743df76a58 100644
(file)
--- 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);
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);
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();
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());
check_promises(NULL, curr->get_cv());
+ break;
+ }
+ default:
+ break;
+ }
/* Assign reads_from values */
Thread *th = get_thread(curr->get_tid());
/* Assign reads_from values */
Thread *th = get_thread(curr->get_tid());