PIThread cxx11 support
git-svn-id: svn://db.shs.com.ru/pip@883 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -172,6 +172,21 @@ PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay)
|
||||
}
|
||||
|
||||
|
||||
#ifdef PIP_CXX11_SUPPORT
|
||||
PIThread::PIThread(std::function<void ()> func, bool startNow, int timer_delay) {
|
||||
PIINTROSPECTION_THREAD_NEW(this);
|
||||
tid_ = -1;
|
||||
PRIVATE->thread = 0;
|
||||
data_ = 0;
|
||||
ret_func = [func](void*){func();};
|
||||
terminating = running_ = lockRun = false;
|
||||
priority_ = piNormal;
|
||||
delay_ = timer_delay;
|
||||
if (startNow) start(timer_delay);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
|
||||
PIINTROSPECTION_THREAD_NEW(this);
|
||||
tid_ = -1;
|
||||
@@ -533,3 +548,11 @@ void PIThread::__thread_func_once__() {
|
||||
_endThread();
|
||||
}
|
||||
|
||||
|
||||
PIThread * PIThread::runOnce(std::function<void ()> func) {
|
||||
PIThread * t = new PIThread();
|
||||
t->setSlot(func);
|
||||
t->startOnce();
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user