X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/0872290a992e2f6db574c18ac36d1987318d477d..4d5ec9803b74d0f3e9c002a92a748bd08b6640ac:/msg_thread.cpp?ds=sidebyside diff --git a/msg_thread.cpp b/msg_thread.cpp index 41c4bfb..309d573 100644 --- a/msg_thread.cpp +++ b/msg_thread.cpp @@ -8,14 +8,14 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(thrd); msg_thread::msg_thread() : started(false) - , thread(NULL) + , thread(nullptr) , thread_name("msg_thread") { } msg_thread::msg_thread(const char* name) : started(false) - , thread(NULL) + , thread(nullptr) , thread_name(name) { } @@ -23,14 +23,14 @@ msg_thread::msg_thread(const char* name) msg_thread::~msg_thread() { if (thread) - throw std::logic_error("trying to destroy running thread"); + xbt_die("ERROR: trying to destroy running thread"); } void msg_thread::start() { mutex.acquire(); if (started) - throw std::logic_error("thread was already started"); + xbt_die("ERROR: thread was already started"); XBT_DEBUG("launch \"%s\"", thread_name.c_str()); thread = MSG_process_create(thread_name.c_str(), msg_thread::start_wrapper, @@ -43,7 +43,7 @@ void msg_thread::wait() { mutex.acquire(); if (!started) - throw std::logic_error("trying to wait a thread that was not started"); + xbt_die("ERROR: trying to wait for a thread that was not started"); while (thread) { XBT_DEBUG("waiting for \"%s\" to terminate", thread_name.c_str()); @@ -61,7 +61,7 @@ int msg_thread::start_wrapper(int, char* []) XBT_DEBUG("terminate \"%s\"", self->thread_name.c_str()); self->mutex.acquire(); - self->thread = NULL; + self->thread = nullptr; self->cond.signal(); self->mutex.release(); return 0;