model / threads: remove global get_next_id() interface
authorBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 02:31:58 +0000 (19:31 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 02:31:58 +0000 (19:31 -0700)
execution.cc
model.cc
model.h
threads-model.h
threads.cc

index 0ec13900b4e56b4bde68db8978bd9d5202b28946..fe9175b2fb336965e3aa23f867432fabee1441d3 100644 (file)
@@ -911,7 +911,7 @@ bool ModelExecution::process_thread_action(ModelAction *curr)
        case THREAD_CREATE: {
                thrd_t *thrd = (thrd_t *)curr->get_location();
                struct thread_params *params = (struct thread_params *)curr->get_value();
-               Thread *th = new Thread(thrd, params->func, params->arg, get_thread(curr));
+               Thread *th = new Thread(get_next_id(), thrd, params->func, params->arg, get_thread(curr));
                add_thread(th);
                th->set_creation(curr);
                /* Promises can be satisfied by children */
index 55949730f5c2a00428618dd8cfbe8bf65c96747f..03d7ba33b4646f48ed9e5a288ddf66be256c0470 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -436,7 +436,7 @@ void ModelChecker::run()
 {
        do {
                thrd_t user_thread;
-               Thread *t = new Thread(&user_thread, &user_main_wrapper, NULL, NULL);
+               Thread *t = new Thread(execution->get_next_id(), &user_thread, &user_main_wrapper, NULL, NULL);
                execution->add_thread(t);
 
                do {
diff --git a/model.h b/model.h
index 4dbe557222c40a0a7d92fb55227a202d54f069f6..be53ec3fb4ea57858fd55fae54f3b65672b33607 100644 (file)
--- a/model.h
+++ b/model.h
@@ -58,7 +58,6 @@ public:
        bool is_enabled(Thread *t) const;
        bool is_enabled(thread_id_t tid) const;
 
-       thread_id_t get_next_id();
        unsigned int get_num_threads() const;
        Thread * get_current_thread() const;
 
index 5fc6d675aba6a9f05b132ded2ad2aed0ad6250d5..733d825f243ea5ea32a1bde878f37c97448f77b2 100644 (file)
@@ -41,7 +41,7 @@ class ModelAction;
 class Thread {
 public:
        Thread(thread_id_t tid);
-       Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent);
+       Thread(thread_id_t tid, thrd_t *t, void (*func)(void *), void *a, Thread *parent);
        ~Thread();
        void complete();
 
index ae2905a9819a7d4e0159fbbf6d4f439850da1f40..a0bc02970aa9ff71c6e8e1a04f6565d52b6db43a 100644 (file)
@@ -151,13 +151,14 @@ Thread::Thread(thread_id_t tid) :
  * @param func The function that the thread will call.
  * @param a The parameter to pass to this function.
  */
-Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent) :
+Thread::Thread(thread_id_t tid, thrd_t *t, void (*func)(void *), void *a, Thread *parent) :
        parent(parent),
        creation(NULL),
        pending(NULL),
        start_routine(func),
        arg(a),
        user_thread(t),
+       id(tid),
        state(THREAD_CREATED),
        last_action_val(VALUE_NONE),
        model_thread(false)
@@ -169,7 +170,6 @@ Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent) :
        if (ret)
                model_print("Error in create_context\n");
 
-       id = model->get_next_id();
        user_thread->priv = this;
 }