diff options
author | Michi Henning <michi@zeroc.com> | 2002-11-29 01:18:03 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2002-11-29 01:18:03 +0000 |
commit | 404a9441f45ac9ca1ba39f04c7f8d1f9fc79de5b (patch) | |
tree | 12023d167f8ab1b161aaec017a206863f4888bbf /cpp/src/IceUtil/Thread.cpp | |
parent | fixing potential deadlock with ObjectAdapter (diff) | |
download | ice-404a9441f45ac9ca1ba39f04c7f8d1f9fc79de5b.tar.bz2 ice-404a9441f45ac9ca1ba39f04c7f8d1f9fc79de5b.tar.xz ice-404a9441f45ac9ca1ba39f04c7f8d1f9fc79de5b.zip |
Added ThreadControl::detach().
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; |