summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2004-10-21 23:14:23 +0000
committerBernard Normier <bernard@zeroc.com>2004-10-21 23:14:23 +0000
commit1a1e63ec7b59194397cdf36bfa66f858a82b1bce (patch)
tree14a96f6198d9db67e66b3cae44f47ff8e36b0b4c /cpp/src
parentdetach instead of join (diff)
downloadice-1a1e63ec7b59194397cdf36bfa66f858a82b1bce.tar.bz2
ice-1a1e63ec7b59194397cdf36bfa66f858a82b1bce.tar.xz
ice-1a1e63ec7b59194397cdf36bfa66f858a82b1bce.zip
Added stack-size param to start
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceUtil/Thread.cpp40
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;