trunk/branch integration: VxWorks & Wince

This commit is contained in:
Marian Krivos
2011-08-23 07:12:01 +00:00
parent ccbcadd4ab
commit c349742cf5
4 changed files with 59 additions and 54 deletions

View File

@@ -1,7 +1,7 @@
// //
// Thread.cpp // Thread.cpp
// //
// $Id: //poco/Main/Foundation/src/Thread.cpp#16 $ // $Id: //poco/1.4/Foundation/src/Thread.cpp#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading
@@ -47,6 +47,8 @@
#else #else
#include "Thread_WIN32.cpp" #include "Thread_WIN32.cpp"
#endif #endif
#elif defined(POCO_VXWORKS)
#include "Thread_VX.cpp"
#else #else
#include "Thread_POSIX.cpp" #include "Thread_POSIX.cpp"
#endif #endif

View File

@@ -188,19 +188,19 @@ void PooledThread::release()
{ {
const long JOIN_TIMEOUT = 10000; const long JOIN_TIMEOUT = 10000;
_mutex.lock(); _mutex.lock();
_pTarget = 0; _pTarget = 0;
_mutex.unlock(); _mutex.unlock();
// In case of a statically allocated thread pool (such // In case of a statically allocated thread pool (such
// as the default thread pool), Windows may have already // as the default thread pool), Windows may have already
// terminated the thread before we got here. // terminated the thread before we got here.
if (_thread.isRunning()) if (_thread.isRunning())
_targetReady.set(); _targetReady.set();
if (_thread.tryJoin(JOIN_TIMEOUT)) if (_thread.tryJoin(JOIN_TIMEOUT))
{ {
delete this; delete this;
} }
} }
@@ -467,17 +467,17 @@ PooledThread* ThreadPool::getThread()
{ {
if (_threads.size() < _maxCapacity) if (_threads.size() < _maxCapacity)
{ {
pThread = createThread(); pThread = createThread();
try try
{ {
pThread->start(); pThread->start();
_threads.push_back(pThread); _threads.push_back(pThread);
} }
catch(SystemException& e) catch (...)
{ {
delete pThread; delete pThread;
throw; throw;
} }
} }
else throw NoThreadAvailableException(); else throw NoThreadAvailableException();
} }

View File

@@ -161,13 +161,15 @@ void ThreadImpl::setStackSizeImpl(int size)
{ {
#if defined(__APPLE__) #if defined(__APPLE__)
// we must round up to a multiple of the memory page size // we must round up to a multiple of the memory page size
const int PAGE_SIZE = 4096; const int PAGE_SIZE = 4096;
size = ((size + PAGE_SIZE - 1)/PAGE_SIZE)*PAGE_SIZE; size = ((size + PAGE_SIZE - 1)/PAGE_SIZE)*PAGE_SIZE;
#endif #endif
if (size < PTHREAD_STACK_MIN) #if !defined(POCO_ANDROID)
size = PTHREAD_STACK_MIN; if (size < PTHREAD_STACK_MIN)
} size = PTHREAD_STACK_MIN;
_pData->stackSize = size; #endif
}
_pData->stackSize = size;
#endif #endif
} }

View File

@@ -141,11 +141,12 @@ void ThreadImpl::startImpl(Runnable& target)
void ThreadImpl::startImpl(Callable target, void* pData) void ThreadImpl::startImpl(Callable target, void* pData)
{ {
if (isRunningImpl()) if (isRunningImpl())
throw SystemException("thread already running"); throw SystemException("thread already running");
_callbackTarget.callback = target; threadCleanup();
_callbackTarget.pData = pData; _callbackTarget.callback = target;
_callbackTarget.pData = pData;
createImpl(callableEntry, this); createImpl(callableEntry, this);
} }