diff options
author | Michi Henning <michi@zeroc.com> | 2002-12-02 04:56:39 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2002-12-02 04:56:39 +0000 |
commit | c3b16c1d6638143ec4334775846b2d2c7b4f3d96 (patch) | |
tree | 641015f47f4647cd6657e322a1acaf7749b61605 /cpp/src/IceUtil/Thread.cpp | |
parent | file IncomingAsyncF.h was initially added on branch amd. (diff) | |
download | ice-c3b16c1d6638143ec4334775846b2d2c7b4f3d96.tar.bz2 ice-c3b16c1d6638143ec4334775846b2d2c7b4f3d96.tar.xz ice-c3b16c1d6638143ec4334775846b2d2c7b4f3d96.zip |
Added ThreadStartedException and appropriate test in Thread::start() to
catch re-use of a Thread object.
Diffstat (limited to 'cpp/src/IceUtil/Thread.cpp')
-rw-r--r-- | cpp/src/IceUtil/Thread.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index 29853280530..067bd721d76 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -22,6 +22,7 @@ using namespace std; IceUtil::ThreadControl::ThreadControl() : _handle(new HandleWrapper(0)), + _detached(false), _id(GetCurrentThreadId()) { HANDLE proc = GetCurrentProcess(); @@ -35,8 +36,8 @@ IceUtil::ThreadControl::ThreadControl() : IceUtil::ThreadControl::ThreadControl(const HandleWrapperPtr& handle, unsigned id) : _handle(handle), - _id(id), - _detached(false) + _detached(false), + _id(id) { } @@ -109,6 +110,7 @@ IceUtil::ThreadControl::yield() } IceUtil::Thread::Thread() : + _started(false), _id(0), _handle(new HandleWrapper(0)) { @@ -156,6 +158,12 @@ startHook(void* arg) IceUtil::ThreadControl IceUtil::Thread::start() { + if(_started) + { + throw ThreadStartedException(__FILE__, __LINE__); + } + _started = true; + // // It's necessary to increment the reference count since // pthread_create won't necessarily call the thread function until @@ -275,7 +283,9 @@ IceUtil::ThreadControl::yield() sched_yield(); } -IceUtil::Thread::Thread() +IceUtil::Thread::Thread() : + _started(false), + _id(0) { } @@ -321,6 +331,12 @@ startHook(void* arg) IceUtil::ThreadControl IceUtil::Thread::start() { + if(_started) + { + throw ThreadStartedException(__FILE__, __LINE__); + } + _started = true; + // // It's necessary to increment the reference count since // pthread_create won't necessarily call the thread function until |