serialized access to startImpl() functions

This commit is contained in:
Aleksandar Fabijanic
2008-04-11 09:27:41 +00:00
parent 89ca50a581
commit 01613f5cf6
2 changed files with 6 additions and 0 deletions

View File

@@ -42,6 +42,7 @@
#include "Poco/Foundation.h"
#include "Poco/Runnable.h"
#include "Poco/Mutex.h"
#include "Poco/UnWindows.h"
@@ -117,6 +118,7 @@ private:
HANDLE _thread;
int _prio;
std::size_t _stackSize;
Mutex _mutex;
static DWORD _currentKey;
};

View File

@@ -83,6 +83,8 @@ void ThreadImpl::setPriorityImpl(int prio)
void ThreadImpl::startImpl(Runnable& target)
{
Mutex::ScopedLock lock(_mutex);
if (isRunningImpl())
throw SystemException("thread already running");
@@ -94,6 +96,8 @@ void ThreadImpl::startImpl(Runnable& target)
void ThreadImpl::startImpl(Callback target, void* pData)
{
Mutex::ScopedLock lock(_mutex);
if (isRunningImpl())
throw SystemException("thread already running");