X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fthread.cpp;h=ad78d945cbd85e995d954ba6411964ccaa702421;hb=1787d4928ac1285f5434a2c8d0676deea9ce9176;hp=721e8cfef51f2ff772c304ff9ece65554c3f033a;hpb=1a563cfd722a5571428562259790b4948980dd4f;p=libs%2Fcore.git diff --git a/source/core/thread.cpp b/source/core/thread.cpp index 721e8cf..ad78d94 100644 --- a/source/core/thread.cpp +++ b/source/core/thread.cpp @@ -1,4 +1,4 @@ -#include +#include "except.h" #include "thread.h" #include "thread_private.h" @@ -7,43 +7,42 @@ using namespace std; namespace Msp { Thread::Thread(const string &name): - priv_(new Private), - name_(name), - state_(PENDING) + _priv(new Private), + _name(name) { } Thread::~Thread() { kill(); join(); - delete priv_; + delete _priv; } void Thread::join() { - if(state_>=JOINED) + if(_state>=JOINED) return; platform_join(); - state_ = JOINED; + _state = JOINED; } void Thread::kill() { - if(state_!=RUNNING) + if(_state!=RUNNING) return; platform_kill(); - state_ = KILLED; + _state = KILLED; } void Thread::launch() { - if(state_>=RUNNING) - throw logic_error("already launched"); + if(_state>=RUNNING) + throw already_called("Thread::launch"); platform_launch(); - state_ = RUNNING; + _state = RUNNING; } ThreadReturn THREAD_CALL Thread::Private::main_wrapper(void *arg) @@ -51,7 +50,7 @@ ThreadReturn THREAD_CALL Thread::Private::main_wrapper(void *arg) Thread *thread = reinterpret_cast(arg); thread->platform_setname(); thread->main(); - thread->state_ = FINISHED; + thread->_state = FINISHED; return 0; }