diff --git a/uppsrc/Core/Core.h b/uppsrc/Core/Core.h index aa80a8f13..26a14c7d1 100644 --- a/uppsrc/Core/Core.h +++ b/uppsrc/Core/Core.h @@ -419,8 +419,6 @@ NAMESPACE_UPP #include "Vcont.hpp" #include "Index.hpp" -#include "Mt2.h" - #include "Value.h" #include "Gtypes.h" #include "Color.h" diff --git a/uppsrc/Core/Mt.h b/uppsrc/Core/Mt.h index fa3a7e270..f07c059e0 100644 --- a/uppsrc/Core/Mt.h +++ b/uppsrc/Core/Mt.h @@ -258,7 +258,10 @@ inline int AtomicDec(volatile Atomic& t) { return AtomicXAdd(t, -1) class Mutex : NoCopy { pthread_mutex_t mutex[1]; +#ifdef flagPROFILEMT MtInspector *mti; +#endif + friend class ConditionVariable; public: #ifdef flagPROFILEMT @@ -293,6 +296,19 @@ public: struct WriteLock; }; +class ConditionVariable { + pthread_cond_t cv[1]; + +public: + void Wait(Mutex& m) { pthread_cond_wait(cv, m.mutex); } + + void Signal() { pthread_cond_signal(cv); } + void Broadcast() { pthread_cond_broadcast(cv); } + + ConditionVariable() { pthread_cond_init(cv, NULL); } + ~ConditionVariable() { pthread_cond_destroy(cv); } +}; + #endif inline int AtomicRead(const volatile Atomic& t) { return ReadWithBarrier(t); }