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

@@ -26,6 +26,7 @@
#include "Poco/Event.h"
#include "Poco/RefCountedObject.h"
#include "Poco/AutoPtr.h"
#include "Poco/SharedPtr.h"
#include <pthread.h>
// must be limits.h (not <climits>) for PTHREAD_STACK_MIN on Solaris
#include <limits.h>
@@ -61,16 +62,6 @@ public:
POLICY_DEFAULT_IMPL = SCHED_OTHER
};
struct CallbackData: public RefCountedObject
{
CallbackData(): callback(0), pData(0)
{
}
Callable callback;
void* pData;
};
ThreadImpl();
~ThreadImpl();
@@ -83,9 +74,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;
@@ -129,8 +118,6 @@ private:
struct ThreadData: public RefCountedObject
{
ThreadData():
pRunnableTarget(0),
pCallbackTarget(0),
thread(0),
prio(PRIO_NORMAL_IMPL),
policy(SCHED_OTHER),
@@ -146,8 +133,7 @@ private:
#endif
}
Runnable* pRunnableTarget;
AutoPtr<CallbackData> pCallbackTarget;
SharedPtr<Runnable> pRunnableTarget;
pthread_t thread;
int prio;
int osPrio;