mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-22 22:02:34 -06:00
ConditionVariable: POSIX implementation
git-svn-id: svn://ultimatepp.org/upp/trunk@941 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
30c500d4e6
commit
51457751f2
2 changed files with 16 additions and 2 deletions
|
|
@ -419,8 +419,6 @@ NAMESPACE_UPP
|
|||
#include "Vcont.hpp"
|
||||
#include "Index.hpp"
|
||||
|
||||
#include "Mt2.h"
|
||||
|
||||
#include "Value.h"
|
||||
#include "Gtypes.h"
|
||||
#include "Color.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); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue