added support for starting functors/lambdas to Poco::Thread class

This commit is contained in:
Günter Obiltschnig
2014-11-16 20:43:19 +01:00
parent 28982f9fcc
commit 7043a3d4ff
8 changed files with 142 additions and 147 deletions

View File

@@ -22,6 +22,7 @@
#include "Poco/Foundation.h"
#include "Poco/Runnable.h"
#include "Poco/SharedPtr.h"
#include "Poco/UnWindows.h"
@@ -40,16 +41,6 @@ public:
typedef unsigned (__stdcall *Entry)(void*);
#endif
struct CallbackData
{
CallbackData(): callback(0), pData(0)
{
}
Callable callback;
void* pData;
};
enum Priority
{
PRIO_LOWEST_IMPL = THREAD_PRIORITY_LOWEST,
@@ -76,9 +67,7 @@ public:
static int getMaxOSPriorityImpl(int policy);
void setStackSizeImpl(int size);
int getStackSizeImpl() const;
void startImpl(Runnable& target);
void startImpl(Callable target, void* pData = 0);
void startImpl(SharedPtr<Runnable> pTarget);
void joinImpl();
bool joinImpl(long milliseconds);
bool isRunningImpl() const;
@@ -94,12 +83,6 @@ protected:
static unsigned __stdcall runnableEntry(void* pThread);
#endif
#if defined(_DLL)
static DWORD WINAPI callableEntry(LPVOID pThread);
#else
static unsigned __stdcall callableEntry(void* pThread);
#endif
void createImpl(Entry ent, void* pData);
void threadCleanup();
@@ -129,12 +112,11 @@ private:
DWORD _slot;
};
Runnable* _pRunnableTarget;
CallbackData _callbackTarget;
HANDLE _thread;
DWORD _threadId;
int _prio;
int _stackSize;
SharedPtr<Runnable> _pRunnableTarget;
HANDLE _thread;
DWORD _threadId;
int _prio;
int _stackSize;
static CurrentThreadHolder _currentThreadHolder;
};