From 1a1e63ec7b59194397cdf36bfa66f858a82b1bce Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Thu, 21 Oct 2004 23:14:23 +0000 Subject: Added stack-size param to start --- cpp/src/IceUtil/Thread.cpp | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'cpp/src') 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 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; -- cgit v1.2.3