34 #ifndef PTLIB_SYNCTHRD_H
35 #define PTLIB_SYNCTHRD_H
174 void PrintOn(ostream & strm)
const;
189 operator int()
const {
return value; }
317 Nest() { readerCount = writerCount = 0; }
318 unsigned readerCount;
319 unsigned writerCount;
321 typedef std::map<PThreadIdentifier, Nest>
NestMap;
410 #endif // PTLIB_SYNCTHRD_H
void EndRead()
This function attempts to release the mutex for reading.
This class defines a thread synchronisation object.
Definition: semaphor.h:78
Greater than.
Definition: syncthrd.h:156
PIntCondMutex & operator=(int newval)
Assign new condition value.
void InternalWait(PSemaphore &semaphore) const
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
This is a PCondMutex for which the conditional is the value of an integer.
Definition: syncthrd.h:138
PIntCondMutex & operator--()
Decrement condition value.
std::map< PThreadIdentifier, Nest > NestMap
Definition: syncthrd.h:321
PSemaphore writerSemaphore
Definition: syncthrd.h:310
virtual void Signal()
If there are waiting (blocked) threads then unblock the first one that was blocked.
void StartWrite()
This function attempts to acquire the mutex for writing.
void PrintOn(ostream &strm) const
Print the object on the stream.
void StartRead()
This function attempts to acquire the mutex for reading.
Definition: syncthrd.h:314
~PWriteWaitAndSignal()
End write operation on the PReadWriteMutex.
PSyncPoint syncPoint
Definition: syncthrd.h:132
PWriteWaitAndSignal(const PReadWriteMutex &rw, PBoolean start=true)
Create the PWriteWaitAndSignal wait instance.
int value
Definition: syncthrd.h:239
PIntCondMutex & operator+=(int inc)
Add to condition value.
PIntCondMutex & operator++()
Increment condition value.
virtual void WaitCondition()
This function attempts to acquire the mutex, but will block not only until the mutex is free...
NestMap m_nestedThreads
Definition: syncthrd.h:322
BOOL PBoolean
Definition: object.h:102
This class defines a thread synchronisation object.
Definition: syncthrd.h:103
Operation
defines possible operators on current value and target value
Definition: syncthrd.h:146
virtual void OnWait()
This function is called immediately before blocking on the condition in the WaitCondition() function...
unsigned readerCount
Definition: syncthrd.h:307
PReadWriteMutex & mutex
Definition: syncthrd.h:368
PReadWriteMutex & mutex
Definition: syncthrd.h:406
PSyncPoint ack
Definition: syncthrd.h:94
This class starts a read operation for the PReadWriteMutex on construction and automatically ends the...
Definition: syncthrd.h:351
Operation operation
Definition: syncthrd.h:240
unsigned writerCount
Definition: syncthrd.h:312
int target
Definition: syncthrd.h:239
PMutex m_nestingMutex
Definition: syncthrd.h:323
Less than or equal to.
Definition: syncthrd.h:150
Equal to.
Definition: syncthrd.h:152
PReadWaitAndSignal(const PReadWriteMutex &rw, PBoolean start=true)
Create the PReadWaitAndSignal wait instance.
Greater than or equal to.
Definition: syncthrd.h:154
This class starts a write operation for the PReadWriteMutex on construction and automatically ends th...
Definition: syncthrd.h:389
virtual PBoolean Condition()=0
This is the condition that must be met for the WaitCondition() function to acquire the mutex...
PIntCondMutex(int value=0, int target=0, Operation operation=LE)
Create a cond mutex using an integer.
void EndWrite()
This function attempts to release the mutex for writing.
PIntCondMutex & operator-=(int dec)
Subtract from condition value.
PMutex readerMutex
Definition: syncthrd.h:306
virtual void Signal()
If there are waiting (blocked) threads then unblock the first one that was blocked.
This class defines a thread synchronisation object.
Definition: syncthrd.h:251
Less than.
Definition: syncthrd.h:148
void Acknowledge()
This indicates that the thread that was blocked in a Wait() on this synchronisation object has comple...
PMutex writerMutex
Definition: syncthrd.h:311
This class defines a thread synchronisation object.
Definition: syncthrd.h:67
~PReadWaitAndSignal()
End read operation on the PReadWriteMutex.
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PSemaphore readerSemaphore
Definition: syncthrd.h:305
This class defines a thread synchronisation object.
Definition: syncpoint.h:67
PMutex starvationPreventer
Definition: syncthrd.h:308
virtual PBoolean Condition()
This is the condition that must be met for the WaitCondition() function to acquire the mutex...