model: index thread_map by int, not thread_id_t
authorBrian Norris <banorris@uci.edu>
Tue, 1 May 2012 20:24:35 +0000 (13:24 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 1 May 2012 20:24:35 +0000 (13:24 -0700)
model.cc
model.h

index f541d48d6114a25c5602fcadda7af1a4377df293..18d7dd8a5dbec0ffd3a364325988e4ae3cf86609 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -37,7 +37,7 @@ ModelChecker::~ModelChecker()
 void ModelChecker::reset_to_initial_state()
 {
        DEBUG("+++ Resetting to initial state +++\n");
 void ModelChecker::reset_to_initial_state()
 {
        DEBUG("+++ Resetting to initial state +++\n");
-       std::map<thread_id_t, class Thread *>::iterator it;
+       std::map<int, class Thread *>::iterator it;
        for (it = thread_map.begin(); it != thread_map.end(); it++)
                delete (*it).second;
        thread_map.clear();
        for (it = thread_map.begin(); it != thread_map.end(); it++)
                delete (*it).second;
        thread_map.clear();
@@ -58,7 +58,7 @@ Thread * ModelChecker::schedule_next_thread()
        Thread *t;
        if (nextThread == THREAD_ID_T_NONE)
                return NULL;
        Thread *t;
        if (nextThread == THREAD_ID_T_NONE)
                return NULL;
-       t = thread_map[nextThread];
+       t = thread_map[id_to_int(nextThread)];
        if (t == NULL)
                DEBUG("*** error: thread not in thread_map: id = %d\n", nextThread);
        return t;
        if (t == NULL)
                DEBUG("*** error: thread not in thread_map: id = %d\n", nextThread);
        return t;
@@ -219,7 +219,7 @@ void ModelChecker::print_summary(void)
 
 int ModelChecker::add_thread(Thread *t)
 {
 
 int ModelChecker::add_thread(Thread *t)
 {
-       thread_map[t->get_id()] = t;
+       thread_map[id_to_int(t->get_id())] = t;
        scheduler->add_thread(t);
        return 0;
 }
        scheduler->add_thread(t);
        return 0;
 }
diff --git a/model.h b/model.h
index 3e644f2792df519b67c7452f959cacd1fd791593..b2bcb96f54a79513a6eb7c7890c796a4203f0299 100644 (file)
--- a/model.h
+++ b/model.h
@@ -51,7 +51,7 @@ public:
 
        int add_thread(Thread *t);
        void remove_thread(Thread *t);
 
        int add_thread(Thread *t);
        void remove_thread(Thread *t);
-       Thread * get_thread(thread_id_t tid) { return thread_map[tid]; }
+       Thread * get_thread(thread_id_t tid) { return thread_map[id_to_int(tid)]; }
 
        thread_id_t get_next_id();
 
 
        thread_id_t get_next_id();
 
@@ -75,7 +75,7 @@ private:
 
        ucontext_t *system_context;
        action_list_t *action_trace;
 
        ucontext_t *system_context;
        action_list_t *action_trace;
-       std::map<thread_id_t, class Thread *> thread_map;
+       std::map<int, class Thread *> thread_map;
        class TreeNode *rootNode, *currentNode;
        std::list<class Backtrack *> backtrack_list;
 };
        class TreeNode *rootNode, *currentNode;
        std::list<class Backtrack *> backtrack_list;
 };