#15 убрать PIP_CXX11_SUPPORT

This commit is contained in:
2020-07-17 11:51:30 +03:00
parent 33a6382f4d
commit b772928dc1
11 changed files with 8 additions and 92 deletions

View File

@@ -184,7 +184,6 @@ 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;
@@ -196,7 +195,6 @@ PIThread::PIThread(std::function<void ()> func, bool startNow, int timer_delay)
delay_ = timer_delay;
if (startNow) start(timer_delay);
}
#endif
PIThread::PIThread(bool startNow, int timer_delay): PIObject() {

View File

@@ -60,11 +60,7 @@ public:
static __PIThreadCollection_Initializer__ __PIThreadCollection_initializer__;
#ifdef PIP_CXX11_SUPPORT
typedef std::function<void(void *)> ThreadFunc;
#else
typedef void (*ThreadFunc)(void * );
#endif
class PIP_EXPORT PIThread: public PIObject
{
@@ -76,10 +72,8 @@ public:
//! Contructs thread with custom data "data", external function "func" and main loop delay "loop_delay".
PIThread(void * data, ThreadFunc func, bool startNow = false, int loop_delay = -1);
#ifdef PIP_CXX11_SUPPORT
//! Contructs thread with external function "func" and main loop delay "loop_delay".
PIThread(std::function<void()> func, bool startNow = false, int loop_delay = -1);
#endif
//! Contructs thread with main loop delay "loop_delay".
PIThread(bool startNow = false, int loop_delay = -1);
@@ -99,10 +93,8 @@ public:
EVENT_HANDLER1(bool, start, int, timer_delay);
bool start(ThreadFunc func) {return start(func, -1);}
bool start(ThreadFunc func, int timer_delay) {ret_func = func; return start(timer_delay);}
#ifdef PIP_CXX11_SUPPORT
bool start(std::function<void()> func) {return start(func, -1);}
bool start(std::function<void()> func, int timer_delay) {ret_func = [func](void*){func();}; return start(timer_delay);}
#endif
EVENT_HANDLER0(bool, startOnce);
EVENT_HANDLER1(bool, startOnce, ThreadFunc, func) {ret_func = func; return startOnce();}
EVENT_HANDLER0(void, stop) {stop(false);}
@@ -115,10 +107,8 @@ public:
//! \brief Set external function that will be executed after every \a run()
void setSlot(ThreadFunc func) {ret_func = func;}
#ifdef PIP_CXX11_SUPPORT
//! \brief Set external function that will be executed after every \a run()
void setSlot(std::function<void()> func) {ret_func = [func](void*){func();};}
#endif
//! \brief Set priority of thread
void setPriority(PIThread::Priority prior);
@@ -161,11 +151,9 @@ public:
//! and automatically delete it on function finish
static void runOnce(PIObject * object, const char * handler, const PIString & name = PIString());
#ifdef PIP_CXX11_SUPPORT
//! \brief Start function \"func\" in separate thread with name \"name\"
//! and automatically delete it on function finish
static void runOnce(std::function<void()> func, const PIString & name = PIString());
#endif
//! \handlers
//! \{

View File

@@ -479,7 +479,6 @@ PITimer::PITimer(TimerEvent slot, void * data, PITimer::TimerImplementation ti):
}
#ifdef PIP_CXX11_SUPPORT
PITimer::PITimer(std::function<void ()> slot, PITimer::TimerImplementation ti) {
imp_mode = ti;
initFirst();
@@ -493,7 +492,7 @@ PITimer::PITimer(std::function<void (void *)> slot, void * data, PITimer::TimerI
data_t = data;
ret_func = [slot](void *d, int){slot(d);};
}
#endif
PITimer::~PITimer() {
destroy();

View File

@@ -26,11 +26,7 @@
#include "pithread.h"
#include "pitime.h"
#ifdef PIP_CXX11_SUPPORT
typedef std::function<void(void *, int)> TimerEvent;
#else
typedef void (*TimerEvent)(void *, int);
#endif
class PITimer;
@@ -97,13 +93,11 @@ public:
//! \brief Constructs timer with "slot" slot void(void *,int), "data" data and "ti" implementation
explicit PITimer(TimerEvent slot, void * data = 0, TimerImplementation ti = Thread);
#ifdef PIP_CXX11_SUPPORT
//! \brief Constructs timer with "slot" slot void(), and "ti" implementation
explicit PITimer(std::function<void ()> slot, TimerImplementation ti = Thread);
//! \brief Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation
explicit PITimer(std::function<void (void *)> slot, void * data, TimerImplementation ti = Thread);
#endif
virtual ~PITimer();
@@ -160,13 +154,11 @@ public:
//! \brief Set timer tick function
void setSlot(TimerEvent slot) {ret_func = slot;}
#ifdef PIP_CXX11_SUPPORT
//! \brief Set timer tick function
void setSlot(std::function<void ()> slot) {ret_func = [slot](void *, int){slot();};}
//! \brief Set timer tick function
void setSlot(std::function<void (void *)> slot) {ret_func = [slot](void *d, int){slot(d);};}
#endif
//! \brief Returns common data passed to tick functions
void * data() const {return data_t;}
@@ -186,13 +178,11 @@ public:
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
void addDelimiter(int delim, TimerEvent slot = 0) {delims << Delimiter(slot, delim);}
#ifdef PIP_CXX11_SUPPORT
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
void addDelimiter(int delim, std::function<void ()> slot) {delims << Delimiter([slot](void *, int){slot();}, delim);}
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
void addDelimiter(int delim, std::function<void (void *)> slot) {delims << Delimiter([slot](void *d, int){slot(d);}, delim);}
#endif
//! \brief Remove all frequency delimiters \b delim.
void removeDelimiter(int delim) {for (int i = 0; i < delims.size_s(); ++i) if (delims[i].delim == delim) {delims.remove(i); i--;}}