X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=threads.cc;fp=threads.cc;h=d170b7ada3554da89213ab6219fff15c11ed0019;hb=09b2cb3cabe0d96f62383a8fdd040e7605a1ffc6;hp=87de32fb2452f0384016353306b0b0b43c3d4cea;hpb=a330eb33b1b62dfa71f3f0cb055367a30090c180;p=model-checker.git diff --git a/threads.cc b/threads.cc index 87de32f..d170b7a 100644 --- a/threads.cc +++ b/threads.cc @@ -104,12 +104,11 @@ int Thread::swap(ucontext_t *ctxt, Thread *t) /** Terminate a thread and free its stack. */ void Thread::complete() { - if (!is_complete()) { - DEBUG("completed thread %d\n", id_to_int(get_id())); - state = THREAD_COMPLETED; - if (stack) - stack_free(stack); - } + ASSERT(!is_complete()); + DEBUG("completed thread %d\n", id_to_int(get_id())); + state = THREAD_COMPLETED; + if (stack) + stack_free(stack); } /** @@ -169,7 +168,8 @@ Thread::Thread(thrd_t *t, void (*func)(void *), void *a) : /** Destructor */ Thread::~Thread() { - complete(); + if (!is_complete()) + complete(); model->remove_thread(this); }