added stack size argument to ThreadPool constructor

This commit is contained in:
Aleksandar Fabijanic 2008-04-21 23:29:13 +00:00
parent 9fd70bade2
commit 621c98d358
2 changed files with 22 additions and 7 deletions

View File

@ -69,14 +69,21 @@ class Foundation_API ThreadPool
/// from the pool.
{
public:
ThreadPool(int minCapacity = 2, int maxCapacity = 16, int idleTime = 60);
ThreadPool(const std::string& name, int minCapacity = 2, int maxCapacity = 16, int idleTime = 60);
ThreadPool(int minCapacity = 2,
int maxCapacity = 16,
int idleTime = 60,
int stackSize = POCO_THREAD_STACK_SIZE);
ThreadPool(const std::string& name,
int minCapacity = 2,
int maxCapacity = 16,
int idleTime = 60,
int stackSize = POCO_THREAD_STACK_SIZE);
/// Creates a thread pool with minCapacity threads.
/// If required, up to maxCapacity threads are created
/// a NoThreadAvailableException exception is thrown.
/// If a thread is running idle for more than idleTime seconds,
/// and more than minCapacity threads are running, the thread
/// is killed.
/// is killed. Threads are created with given stack size.
~ThreadPool();
/// Currently running threads will remain active

View File

@ -233,12 +233,16 @@ void PooledThread::run()
}
ThreadPool::ThreadPool(int minCapacity, int maxCapacity, int idleTime):
ThreadPool::ThreadPool(int minCapacity,
int maxCapacity,
int idleTime,
int stackSize):
_minCapacity(minCapacity),
_maxCapacity(maxCapacity),
_idleTime(idleTime),
_serial(0),
_age(0)
_age(0),
_stackSize(stackSize)
{
poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);
@ -251,14 +255,18 @@ ThreadPool::ThreadPool(int minCapacity, int maxCapacity, int idleTime):
}
ThreadPool::ThreadPool(const std::string& name, int minCapacity, int maxCapacity, int idleTime):
ThreadPool::ThreadPool(const std::string& name,
int minCapacity,
int maxCapacity,
int idleTime,
int stackSize):
_name(name),
_minCapacity(minCapacity),
_maxCapacity(maxCapacity),
_idleTime(idleTime),
_serial(0),
_age(0),
_stackSize(0)
_stackSize(stackSize)
{
poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);