diff options
Diffstat (limited to 'cpp/include/IceUtil/Thread.h')
-rw-r--r-- | cpp/include/IceUtil/Thread.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/cpp/include/IceUtil/Thread.h b/cpp/include/IceUtil/Thread.h index 76b4ca82313..5f2e6b837c4 100644 --- a/cpp/include/IceUtil/Thread.h +++ b/cpp/include/IceUtil/Thread.h @@ -23,6 +23,10 @@ class ICE_UTIL_API ThreadControl { public: + // + // Constructs a ThreadControl representing the current thread. + // join and detach cannot be called on such ThreadControl object. + // ThreadControl(); #ifdef _WIN32 @@ -31,12 +35,14 @@ public: ThreadControl(pthread_t); #endif - ThreadControl(const ThreadControl&); - - ~ThreadControl(); - - ThreadControl& operator=(const ThreadControl&); + // + // Default copy destructor, assignment operator and destructor OK + // + // + // == and != are meaningful only before the thread is joined/detached, + // or while the thread is still running. + // bool operator==(const ThreadControl&) const; bool operator!=(const ThreadControl&) const; @@ -83,6 +89,13 @@ private: DWORD _id; #else pthread_t _thread; + + // + // Used to prevent joining/detaching a ThreadControl constructed + // with the default constructor. Only needed to enforce our + // portable join/detach behavior. + // + const bool _detachable; #endif }; @@ -104,8 +117,7 @@ public: bool operator<(const Thread&) const; // - // Check whether a thread is still alive. This is useful to implement - // a non-blocking join(). + // Check whether a thread is still alive. // bool isAlive() const; |