diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2005-07-11 16:41:12 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2005-07-11 16:41:12 +0000 |
commit | 8ff7c2608eb845c3b6b637f4648ae726a11a158b (patch) | |
tree | f1dfb4d3a63752357480561fdd94f37692d8eb47 /cppe/src/IceE/Thread.cpp | |
parent | fix some recent changes to build in J2ME (diff) | |
download | ice-8ff7c2608eb845c3b6b637f4648ae726a11a158b.tar.bz2 ice-8ff7c2608eb845c3b6b637f4648ae726a11a158b.tar.xz ice-8ff7c2608eb845c3b6b637f4648ae726a11a158b.zip |
Put back IceUtil namespace
Diffstat (limited to 'cppe/src/IceE/Thread.cpp')
-rw-r--r-- | cppe/src/IceE/Thread.cpp | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/cppe/src/IceE/Thread.cpp b/cppe/src/IceE/Thread.cpp index f1033a1755d..e6af12c1e26 100644 --- a/cppe/src/IceE/Thread.cpp +++ b/cppe/src/IceE/Thread.cpp @@ -17,47 +17,47 @@ using namespace std; #ifdef _WIN32 -Ice::ThreadControl::ThreadControl() +IceUtil::ThreadControl::ThreadControl() { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _handle = new HandleWrapper(GetCurrentThread(), false); _id = GetCurrentThreadId(); } -Ice::ThreadControl::ThreadControl(const HandleWrapperPtr& handle, ThreadId id) +IceUtil::ThreadControl::ThreadControl(const HandleWrapperPtr& handle, ThreadId id) { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _handle = handle; _id = id; } -Ice::ThreadControl::ThreadControl(const ThreadControl& tc) +IceUtil::ThreadControl::ThreadControl(const ThreadControl& tc) { ThreadId id; HandleWrapperPtr handle; { - Ice::Mutex::Lock lock(tc._stateMutex); + IceUtil::Mutex::Lock lock(tc._stateMutex); id = tc._id; handle = tc._handle; } - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _handle = handle; _id = id; } -Ice::ThreadControl& -Ice::ThreadControl::operator=(const ThreadControl& rhs) +IceUtil::ThreadControl& +IceUtil::ThreadControl::operator=(const ThreadControl& rhs) { if(&rhs != this) { ThreadId id; HandleWrapperPtr handle; { - Ice::Mutex::Lock lock(rhs._stateMutex); + IceUtil::Mutex::Lock lock(rhs._stateMutex); handle = rhs._handle; id = rhs._id; } - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _handle = handle; _id = id; } @@ -65,40 +65,40 @@ Ice::ThreadControl::operator=(const ThreadControl& rhs) } bool -Ice::ThreadControl::operator==(const ThreadControl& rhs) const +IceUtil::ThreadControl::operator==(const ThreadControl& rhs) const { ThreadId id = rhs.id(); - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); return _id == id; } bool -Ice::ThreadControl::operator!=(const ThreadControl& rhs) const +IceUtil::ThreadControl::operator!=(const ThreadControl& rhs) const { return !operator==(rhs); } bool -Ice::ThreadControl::operator<(const ThreadControl& rhs) const +IceUtil::ThreadControl::operator<(const ThreadControl& rhs) const { ThreadId id = rhs.id(); - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); return _id < id; } -Ice::ThreadId -Ice::ThreadControl::id() const +IceUtil::ThreadId +IceUtil::ThreadControl::id() const { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); return _id; } void -Ice::ThreadControl::join() +IceUtil::ThreadControl::join() { HandleWrapperPtr handle; { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); handle = _handle; } int rc = WaitForSingleObject(handle->handle, INFINITE); @@ -109,17 +109,17 @@ Ice::ThreadControl::join() } void -Ice::ThreadControl::detach() +IceUtil::ThreadControl::detach() { // No-op: Windows doesn't have the concept of detaching a thread. } bool -Ice::ThreadControl::isAlive() const +IceUtil::ThreadControl::isAlive() const { HandleWrapperPtr handle; { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); handle = _handle; } DWORD rc; @@ -131,14 +131,14 @@ Ice::ThreadControl::isAlive() const } void -Ice::ThreadControl::sleep(const Time& timeout) +IceUtil::ThreadControl::sleep(const Time& timeout) { long msec = (long)timeout.toMilliSeconds(); Sleep(msec); } void -Ice::ThreadControl::yield() +IceUtil::ThreadControl::yield() { // // A value of zero causes the thread to relinquish the remainder @@ -148,22 +148,22 @@ Ice::ThreadControl::yield() Sleep(0); } -Ice::Thread::Thread() +IceUtil::Thread::Thread() { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _started = false; _id = 0; _handle = new HandleWrapper(0); } -Ice::Thread::~Thread() +IceUtil::Thread::~Thread() { } -Ice::ThreadId -Ice::Thread::id() const +IceUtil::ThreadId +IceUtil::Thread::id() const { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(!_started) { throw ThreadNotStartedException(__FILE__, __LINE__); @@ -176,29 +176,29 @@ startHook(void* arg) { try { - Ice::Thread* rawThread = static_cast<Ice::Thread*>(arg); + IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg); // // Initialize the random number generator in each thread. // - unsigned int seed = static_cast<unsigned int>(Ice::Time::now().toMicroSeconds()); + unsigned int seed = static_cast<unsigned int>(IceUtil::Time::now().toMicroSeconds()); srand(seed); // // Ensure that the thread doesn't go away until run() has // completed. // - Ice::ThreadPtr thread = rawThread; + IceUtil::ThreadPtr thread = rawThread; // - // See the comment in Ice::Thread::start() for details. + // See the comment in IceUtil::Thread::start() for details. // rawThread->__decRef(); thread->run(); } - catch(const Ice::Exception& e) + catch(const IceUtil::Exception& e) { - fprintf(stderr, "Ice::Thread::run(): uncaught exception: %s\n", e.toString()); + fprintf(stderr, "IceUtil::Thread::run(): uncaught exception: %s\n", e.toString()); } return 0; } @@ -207,15 +207,15 @@ startHook(void* arg) #include <process.h> #endif -Ice::ThreadControl -Ice::Thread::start(size_t stackSize) +IceUtil::ThreadControl +IceUtil::Thread::start(size_t stackSize) { // // Keep this alive for the duration of start // - Ice::ThreadPtr keepMe = this; + IceUtil::ThreadPtr keepMe = this; - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(_started) { @@ -251,10 +251,10 @@ Ice::Thread::start(size_t stackSize) return ThreadControl(_handle, _id); } -Ice::ThreadControl -Ice::Thread::getThreadControl() const +IceUtil::ThreadControl +IceUtil::Thread::getThreadControl() const { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(!_started) { throw ThreadNotStartedException(__FILE__, __LINE__); @@ -263,7 +263,7 @@ Ice::Thread::getThreadControl() const } bool -Ice::Thread::operator==(const Thread& rhs) const +IceUtil::Thread::operator==(const Thread& rhs) const { // // Get rhs ID. @@ -273,7 +273,7 @@ Ice::Thread::operator==(const Thread& rhs) const // // Check that this thread was started. // - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(!_started) { throw ThreadNotStartedException(__FILE__, __LINE__); @@ -287,13 +287,13 @@ Ice::Thread::operator==(const Thread& rhs) const } bool -Ice::Thread::operator!=(const Thread& rhs) const +IceUtil::Thread::operator!=(const Thread& rhs) const { return !operator==(rhs); } bool -Ice::Thread::operator<(const Thread& rhs) const +IceUtil::Thread::operator<(const Thread& rhs) const { // // Get rhs ID. @@ -303,7 +303,7 @@ Ice::Thread::operator<(const Thread& rhs) const // // Check that this thread was started. // - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(!_started) { throw ThreadNotStartedException(__FILE__, __LINE__); @@ -318,73 +318,73 @@ Ice::Thread::operator<(const Thread& rhs) const #else -Ice::ThreadControl::ThreadControl(ThreadId id) +IceUtil::ThreadControl::ThreadControl(ThreadId id) { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _id = id; } -Ice::ThreadControl::ThreadControl() +IceUtil::ThreadControl::ThreadControl() { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _id = pthread_self(); } -Ice::ThreadControl::ThreadControl(const ThreadControl& tc) +IceUtil::ThreadControl::ThreadControl(const ThreadControl& tc) { ThreadId id = tc.id(); - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _id = id; } -Ice::ThreadControl& -Ice::ThreadControl::operator=(const ThreadControl& rhs) +IceUtil::ThreadControl& +IceUtil::ThreadControl::operator=(const ThreadControl& rhs) { if(&rhs != this) { ThreadId id = rhs.id(); - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _id = id; } return *this; } bool -Ice::ThreadControl::operator==(const ThreadControl& rhs) const +IceUtil::ThreadControl::operator==(const ThreadControl& rhs) const { ThreadId id = rhs.id(); - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); return pthread_equal(_id, id); } bool -Ice::ThreadControl::operator!=(const ThreadControl& rhs) const +IceUtil::ThreadControl::operator!=(const ThreadControl& rhs) const { return !operator==(rhs); } bool -Ice::ThreadControl::operator<(const ThreadControl& rhs) const +IceUtil::ThreadControl::operator<(const ThreadControl& rhs) const { ThreadId id = rhs.id(); - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); // NOTE: Linux specific return _id < id; } -Ice::ThreadId -Ice::ThreadControl::id() const +IceUtil::ThreadId +IceUtil::ThreadControl::id() const { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); return _id; } void -Ice::ThreadControl::join() +IceUtil::ThreadControl::join() { ThreadId id; { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); id = _id; } void* ignore = 0; @@ -396,11 +396,11 @@ Ice::ThreadControl::join() } void -Ice::ThreadControl::detach() +IceUtil::ThreadControl::detach() { ThreadId id; { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); id = _id; } int rc = pthread_detach(id); @@ -411,12 +411,12 @@ Ice::ThreadControl::detach() } bool -Ice::ThreadControl::isAlive() const +IceUtil::ThreadControl::isAlive() const { int policy; int ret; struct sched_param param; - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); ret = pthread_getschedparam(_id, &policy, ¶m); #ifdef __APPLE__ @@ -429,7 +429,7 @@ Ice::ThreadControl::isAlive() const } void -Ice::ThreadControl::sleep(const Time& timeout) +IceUtil::ThreadControl::sleep(const Time& timeout) { struct timeval tv = timeout; struct timespec ts; @@ -439,26 +439,26 @@ Ice::ThreadControl::sleep(const Time& timeout) } void -Ice::ThreadControl::yield() +IceUtil::ThreadControl::yield() { sched_yield(); } -Ice::Thread::Thread() +IceUtil::Thread::Thread() { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); _started = false; _id = 0; } -Ice::Thread::~Thread() +IceUtil::Thread::~Thread() { } -Ice::ThreadId -Ice::Thread::id() const +IceUtil::ThreadId +IceUtil::Thread::id() const { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(!_started) { throw ThreadNotStartedException(__FILE__, __LINE__); @@ -472,41 +472,41 @@ startHook(void* arg) { try { - Ice::Thread* rawThread = static_cast<Ice::Thread*>(arg); + IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg); // // Ensure that the thread doesn't go away until run() has // completed. // - Ice::ThreadPtr thread = rawThread; + IceUtil::ThreadPtr thread = rawThread; // - // See the comment in Ice::Thread::start() for details. + // See the comment in IceUtil::Thread::start() for details. // rawThread->__decRef(); thread->run(); } - catch(const Ice::Exception& e) + catch(const IceUtil::Exception& e) { - //fprintf(stderr, "Ice::Thread::run(): uncaught exception: %s\n", e.toString()); + //fprintf(stderr, "IceUtil::Thread::run(): uncaught exception: %s\n", e.toString()); } catch(...) { - fprintf(stderr, "Ice::Thread::run(): uncaught exception\n"); + fprintf(stderr, "IceUtil::Thread::run(): uncaught exception\n"); } return 0; } } -Ice::ThreadControl -Ice::Thread::start(size_t stackSize) +IceUtil::ThreadControl +IceUtil::Thread::start(size_t stackSize) { // // Keep this alive for the duration of start // - Ice::ThreadPtr keepMe = this; + IceUtil::ThreadPtr keepMe = this; - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(_started) { @@ -561,10 +561,10 @@ Ice::Thread::start(size_t stackSize) return ThreadControl(_id); } -Ice::ThreadControl -Ice::Thread::getThreadControl() const +IceUtil::ThreadControl +IceUtil::Thread::getThreadControl() const { - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(!_started) { throw ThreadNotStartedException(__FILE__, __LINE__); @@ -573,7 +573,7 @@ Ice::Thread::getThreadControl() const } bool -Ice::Thread::operator==(const Thread& rhs) const +IceUtil::Thread::operator==(const Thread& rhs) const { // // Get rhs ID. @@ -583,7 +583,7 @@ Ice::Thread::operator==(const Thread& rhs) const // // Check that this thread was started. // - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(!_started) { throw ThreadNotStartedException(__FILE__, __LINE__); @@ -597,13 +597,13 @@ Ice::Thread::operator==(const Thread& rhs) const } bool -Ice::Thread::operator!=(const Thread& rhs) const +IceUtil::Thread::operator!=(const Thread& rhs) const { return !operator==(rhs); } bool -Ice::Thread::operator<(const Thread& rhs) const +IceUtil::Thread::operator<(const Thread& rhs) const { // // Get rhs ID. @@ -613,7 +613,7 @@ Ice::Thread::operator<(const Thread& rhs) const // // Check that this thread was started. // - Ice::Mutex::Lock lock(_stateMutex); + IceUtil::Mutex::Lock lock(_stateMutex); if(!_started) { throw ThreadNotStartedException(__FILE__, __LINE__); |