model: add ModelChecker::get_thread(ModelAction *act)
authorBrian Norris <banorris@uci.edu>
Wed, 12 Sep 2012 02:45:57 +0000 (19:45 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 12 Sep 2012 02:45:57 +0000 (19:45 -0700)
Many times, I need to convert ModelAction to a Thread. Overload get_thread() to
make it easier to use.

model.cc
model.h

index 3e54a001a4541b8d5acada69e76c189ff5e82b36..cb7e43f06964a564c05aba4650baf99f792d2c10 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -216,7 +216,7 @@ void ModelChecker::set_backtracking(ModelAction *act)
 {
        ModelAction *prev;
        Node *node;
-       Thread *t = get_thread(act->get_tid());
+       Thread *t = get_thread(act);
 
        prev = get_last_conflict(act);
        if (prev == NULL)
@@ -361,14 +361,14 @@ Thread * ModelChecker::check_current_action(ModelAction *curr)
        }
        case THREAD_JOIN: {
                Thread *wait, *join;
-               wait = get_thread(curr->get_tid());
+               wait = get_thread(curr);
                join = (Thread *)curr->get_location();
                if (!join->is_complete())
                        scheduler->wait(wait, join);
                break;
        }
        case THREAD_FINISH: {
-               Thread *th = get_thread(curr->get_tid());
+               Thread *th = get_thread(curr);
                while (!th->wait_list_empty()) {
                        Thread *wake = th->pop_wait_list();
                        scheduler->wake(wake);
@@ -384,7 +384,7 @@ Thread * ModelChecker::check_current_action(ModelAction *curr)
                break;
        }
 
-       Thread *th = get_thread(curr->get_tid());
+       Thread *th = get_thread(curr);
 
        bool updated = false;
        if (curr->is_read()) {
diff --git a/model.h b/model.h
index c3e5830211c9276ec7b5004504fbb9472df32069..19143d36d4f433c5c734652fbd8fe7ae35a51853 100644 (file)
--- a/model.h
+++ b/model.h
@@ -60,6 +60,7 @@ public:
        void add_thread(Thread *t);
        void remove_thread(Thread *t);
        Thread * get_thread(thread_id_t tid) { return thread_map->get(id_to_int(tid)); }
+       Thread * get_thread(ModelAction *act) { return get_thread(act->get_tid()); }
 
        thread_id_t get_next_id();
        int get_num_threads();