diff options
Diffstat (limited to 'cpp/include/IceUtil')
-rw-r--r-- | cpp/include/IceUtil/RWRecMutex.h | 4 | ||||
-rw-r--r-- | cpp/include/IceUtil/Thread.h | 27 | ||||
-rw-r--r-- | cpp/include/IceUtil/ThreadException.h | 10 |
3 files changed, 28 insertions, 13 deletions
diff --git a/cpp/include/IceUtil/RWRecMutex.h b/cpp/include/IceUtil/RWRecMutex.h index f64d675e368..9e47bdba894 100644 --- a/cpp/include/IceUtil/RWRecMutex.h +++ b/cpp/include/IceUtil/RWRecMutex.h @@ -234,9 +234,9 @@ private: mutable int _count; // - // If there is an active writer this is a control for thread. + // If there is an active writer this is the ID of the writer thread. // - mutable ThreadControl _writerControl; + mutable ThreadId _writerId; // // Number of waiting writers. diff --git a/cpp/include/IceUtil/Thread.h b/cpp/include/IceUtil/Thread.h index 5dbc94365a0..73d0b7e70d9 100644 --- a/cpp/include/IceUtil/Thread.h +++ b/cpp/include/IceUtil/Thread.h @@ -17,6 +17,7 @@ #include <IceUtil/Shared.h> #include <IceUtil/Handle.h> +#include <IceUtil/Mutex.h> namespace IceUtil { @@ -47,6 +48,12 @@ struct HandleWrapper : public Shared typedef Handle<HandleWrapper> HandleWrapperPtr; #endif +#ifdef _WIN32 + typedef unsigned int ThreadId; +#else + typedef pthread_t ThreadId; +#endif + class ICE_UTIL_API ThreadControl { public: @@ -64,6 +71,11 @@ public: bool operator<(const ThreadControl&) const; // + // Return the ID of the thread underlying this ThreadControl. + // + ThreadId id() const; + + // // Wait until the controlled thread terminates. The call has POSIX // semantics. // @@ -97,10 +109,8 @@ private: #ifdef _WIN32 HandleWrapperPtr _handle; - unsigned int _id; -#else - pthread_t _id; #endif + ThreadId _id; bool _detached; }; @@ -108,11 +118,6 @@ private: class ICE_UTIL_API Thread : virtual public IceUtil::Shared { public: -#ifdef _WIN32 - typedef unsigned int ThreadId; -#else - typedef pthread_t ThreadId; -#endif Thread(); virtual ~Thread(); @@ -131,13 +136,13 @@ public: private: + Mutex _stateMutex; + bool _started; #ifdef _WIN32 - unsigned int _id; HandleWrapperPtr _handle; -#else - pthread_t _id; #endif + ThreadId _id; }; typedef Handle<Thread> ThreadPtr; diff --git a/cpp/include/IceUtil/ThreadException.h b/cpp/include/IceUtil/ThreadException.h index aaadc257f7f..a96f0da16c2 100644 --- a/cpp/include/IceUtil/ThreadException.h +++ b/cpp/include/IceUtil/ThreadException.h @@ -54,6 +54,16 @@ public: virtual Exception* ice_clone() const; virtual void ice_throw() const; }; + +class ICE_UTIL_API ThreadNotStartedException : public Exception +{ +public: + + ThreadNotStartedException(const char*, int); + virtual std::string ice_name() const; + virtual Exception* ice_clone() const; + virtual void ice_throw() const; +}; } |