summaryrefslogtreecommitdiff
path: root/cppe/src/IceE/Thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cppe/src/IceE/Thread.cpp')
-rw-r--r--cppe/src/IceE/Thread.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/cppe/src/IceE/Thread.cpp b/cppe/src/IceE/Thread.cpp
index 1b195cd44b7..c3ca404c47b 100644
--- a/cppe/src/IceE/Thread.cpp
+++ b/cppe/src/IceE/Thread.cpp
@@ -44,13 +44,13 @@ IceUtil::ThreadControl::join()
{
if(_handle == 0)
{
- throw BadThreadControlException(__FILE__, __LINE__);
+ throw BadThreadControlException(__FILE__, __LINE__);
}
int rc = WaitForSingleObject(_handle, INFINITE);
if(rc != WAIT_OBJECT_0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
detach();
@@ -61,12 +61,12 @@ IceUtil::ThreadControl::detach()
{
if(_handle == 0)
{
- throw BadThreadControlException(__FILE__, __LINE__);
+ throw BadThreadControlException(__FILE__, __LINE__);
}
if(CloseHandle(_handle) == 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
}
@@ -120,7 +120,7 @@ WINAPI startHook(void* arg)
try
{
- IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);
+ IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);
//
// Initialize the random number generator in each thread.
@@ -128,25 +128,25 @@ WINAPI startHook(void* arg)
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.
- //
- thread = rawThread;
-
- //
- // See the comment in IceUtil::Thread::start() for details.
- //
- rawThread->__decRef();
- thread->run();
+ //
+ // Ensure that the thread doesn't go away until run() has
+ // completed.
+ //
+ thread = rawThread;
+
+ //
+ // See the comment in IceUtil::Thread::start() for details.
+ //
+ rawThread->__decRef();
+ thread->run();
}
catch(const IceUtil::Exception& e)
{
- fprintf(stderr, "IceUtil::Thread::run(): uncaught exception: %s\n", e.toString().c_str());
+ fprintf(stderr, "IceUtil::Thread::run(): uncaught exception: %s\n", e.toString().c_str());
}
catch(...)
{
- fprintf(stderr, "IceUtil::Thread::run(): uncaught exception\n");
+ fprintf(stderr, "IceUtil::Thread::run(): uncaught exception\n");
}
thread->_done();
@@ -169,7 +169,7 @@ IceUtil::Thread::start(size_t stackSize)
if(_started)
{
- throw ThreadStartedException(__FILE__, __LINE__);
+ throw ThreadStartedException(__FILE__, __LINE__);
}
//
@@ -185,26 +185,26 @@ IceUtil::Thread::start(size_t stackSize)
#ifdef _WIN32_WCE
_handle = CreateThread(0, stackSize,
- startHook, this, 0, &_id);
+ startHook, this, 0, &_id);
#else
unsigned int id;
_handle =
- reinterpret_cast<HANDLE>(
- _beginthreadex(0,
- static_cast<unsigned int>(stackSize),
- startHook, this, 0, &id));
+ reinterpret_cast<HANDLE>(
+ _beginthreadex(0,
+ static_cast<unsigned int>(stackSize),
+ startHook, this, 0, &id));
_id = id;
#endif
if(_handle == 0)
{
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
_started = true;
_running = true;
-
+
return ThreadControl(_handle, _id);
}
@@ -214,7 +214,7 @@ IceUtil::Thread::getThreadControl() const
IceUtil::Mutex::Lock lock(_stateMutex);
if(!_started)
{
- throw ThreadNotStartedException(__FILE__, __LINE__);
+ throw ThreadNotStartedException(__FILE__, __LINE__);
}
return ThreadControl(_handle, _id);
}
@@ -283,14 +283,14 @@ IceUtil::ThreadControl::join()
{
if(!_detachable)
{
- throw BadThreadControlException(__FILE__, __LINE__);
+ throw BadThreadControlException(__FILE__, __LINE__);
}
void* ignore = 0;
int rc = pthread_join(_thread, &ignore);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
@@ -299,13 +299,13 @@ IceUtil::ThreadControl::detach()
{
if(!_detachable)
{
- throw BadThreadControlException(__FILE__, __LINE__);
+ throw BadThreadControlException(__FILE__, __LINE__);
}
int rc = pthread_detach(_thread);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
@@ -354,23 +354,23 @@ startHook(void* arg)
try
{
- IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);
+ IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);
- thread = rawThread;
+ thread = rawThread;
- //
- // See the comment in IceUtil::Thread::start() for details.
- //
- rawThread->__decRef();
- thread->run();
+ //
+ // See the comment in IceUtil::Thread::start() for details.
+ //
+ rawThread->__decRef();
+ thread->run();
}
catch(const IceUtil::Exception& e)
{
- fprintf(stderr, "IceUtil::Thread::run(): uncaught exception: %s\n", e.toString().c_str());
+ fprintf(stderr, "IceUtil::Thread::run(): uncaught exception: %s\n", e.toString().c_str());
}
catch(...)
{
- fprintf(stderr, "IceUtil::Thread::run(): uncaught exception\n");
+ fprintf(stderr, "IceUtil::Thread::run(): uncaught exception\n");
}
thread->_done();
@@ -390,7 +390,7 @@ IceUtil::Thread::start(size_t stackSize)
if(_started)
{
- throw ThreadStartedException(__FILE__, __LINE__);
+ throw ThreadStartedException(__FILE__, __LINE__);
}
//
@@ -406,34 +406,34 @@ IceUtil::Thread::start(size_t stackSize)
if(stackSize > 0)
{
- pthread_attr_t attr;
- int rc = pthread_attr_init(&attr);
- if(rc != 0)
- {
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
- rc = pthread_attr_setstacksize(&attr, stackSize);
- if(rc != 0)
- {
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
- rc = pthread_create(&_thread, &attr, startHook, this);
- if(rc != 0)
- {
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ pthread_attr_t attr;
+ int rc = pthread_attr_init(&attr);
+ if(rc != 0)
+ {
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
+ rc = pthread_attr_setstacksize(&attr, stackSize);
+ if(rc != 0)
+ {
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
+ rc = pthread_create(&_thread, &attr, startHook, this);
+ if(rc != 0)
+ {
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
else
{
- int rc = pthread_create(&_thread, 0, startHook, this);
- if(rc != 0)
- {
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ int rc = pthread_create(&_thread, 0, startHook, this);
+ if(rc != 0)
+ {
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
_started = true;
@@ -448,7 +448,7 @@ IceUtil::Thread::getThreadControl() const
IceUtil::Mutex::Lock lock(_stateMutex);
if(!_started)
{
- throw ThreadNotStartedException(__FILE__, __LINE__);
+ throw ThreadNotStartedException(__FILE__, __LINE__);
}
return ThreadControl(_thread);
}