// // Created by fomenko on 20.09.2019. // #ifndef PIP_TESTS_PICONDITIONVAR_H #define PIP_TESTS_PICONDITIONVAR_H #include "piconditionlock.h" #include #include "piinit.h" #define PICONDITION_RELIABLE true class PIP_EXPORT PIConditionVariable { public: explicit PIConditionVariable(); virtual ~PIConditionVariable(); virtual void notifyOne(); virtual void notifyAll(); virtual void wait(PIConditionLock& lk); virtual void wait(PIConditionLock& lk, const std::function& condition); virtual bool waitFor(PIConditionLock& lk, int timeoutMs); virtual bool waitFor(PIConditionLock& lk, int timeoutMs, const std::function& condition); private: NO_COPY_CLASS(PIConditionVariable) PRIVATE_DECLARATION }; class PIThread; typedef void (*ThreadFunc)(void * ); class StdFunctionThreadFuncAdapter { public: static void threadFuncStdFunctionAdapter(void* it); explicit StdFunctionThreadFuncAdapter(const std::function& fun_): fun(fun_) {} void registerToInvoke(PIThread* thread); void* data() const { return (void*)this; } ThreadFunc threadFunc() const { return threadFuncStdFunctionAdapter; } private: std::function fun; }; #endif //PIP_TESTS_PICONDITIONVAR_H