diff options
Diffstat (limited to 'cpp/src/IceUtil/Thread.cpp')
-rw-r--r-- | cpp/src/IceUtil/Thread.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index 41e96cc1ac7..86cb499cb5b 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -35,7 +35,8 @@ IceUtil::ThreadControl::ThreadControl() : IceUtil::ThreadControl::ThreadControl(const HandleWrapperPtr& handle, unsigned id) : _handle(handle), - _id(id) + _id(id), + _detached(false) { } @@ -62,6 +63,11 @@ IceUtil::ThreadControl::join() { if(_handle->handle) { + if (_detached) + { + throw ThreadSyscallException(__FILE__, __LINE__); + } + _detached = true; int rc = WaitForSingleObject(_handle->handle, INFINITE); if(rc != WAIT_OBJECT_0) { @@ -71,6 +77,19 @@ IceUtil::ThreadControl::join() } void +IceUtil::ThreadControl::detach() +{ + if(_handle->handle) + { + if (_detached) + { + throw ThreadSyscallException(__FILE__, __LINE__); + } + _detached = true; + } +} + +void IceUtil::ThreadControl::sleep(const Time& timeout) { timeval tv = timeout; @@ -228,6 +247,19 @@ IceUtil::ThreadControl::join() } void +IceUtil::ThreadControl::detach() +{ + if(_id) + { + int rc = pthread_detach(_id); + if(rc != 0) + { + throw ThreadSyscallException(__FILE__, __LINE__); + } + } +} + +void IceUtil::ThreadControl::sleep(const Time& timeout) { struct timeval tv = timeout; |