diff options
Diffstat (limited to 'cpp/src/IceUtil/Thread.cpp')
-rw-r--r-- | cpp/src/IceUtil/Thread.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index 1e3e32c0bb0..5011bfa5a7e 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -213,7 +213,7 @@ startHook(void* arg) #include <process.h> IceUtil::ThreadControl -IceUtil::Thread::start() +IceUtil::Thread::start(size_t stackSize) { // // Keep this alive for the duration of start @@ -238,7 +238,7 @@ IceUtil::Thread::start() // __incRef(); - _handle->handle = (HANDLE)_beginthreadex(0, 0, (unsigned int (__stdcall*)(void*))startHook, (LPVOID)this, 0, &_id); + _handle->handle = (HANDLE)_beginthreadex(0, stack_size, (unsigned int (__stdcall*)(void*))startHook, (LPVOID)this, 0, &_id); if(_handle->handle == 0) { __decRef(); @@ -499,7 +499,7 @@ startHook(void* arg) } IceUtil::ThreadControl -IceUtil::Thread::start() +IceUtil::Thread::start(size_t stackSize) { // // Keep this alive for the duration of start @@ -523,11 +523,37 @@ IceUtil::Thread::start() // __decRef(). // __incRef(); - int rc = pthread_create(&_id, 0, startHook, this); - if(rc != 0) + + if(stackSize > 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(&_id, &attr, startHook, this); + if(rc != 0) + { + __decRef(); + throw ThreadSyscallException(__FILE__, __LINE__, rc); + } + } + else + { + int rc = pthread_create(&_id, 0, startHook, this); + if(rc != 0) + { + __decRef(); + throw ThreadSyscallException(__FILE__, __LINE__, rc); + } } _started = true; |