1
0
mirror of https://github.com/anope/anope.git synced 2026-07-07 04:03:12 +02:00

Replace Condition and Mutex with the C++11 standard equivalents.

This commit is contained in:
Sadie Powell
2024-02-11 19:53:05 +00:00
parent 5c50bcb9c7
commit 2c5b84bd1d
4 changed files with 59 additions and 149 deletions
-55
View File
@@ -59,58 +59,3 @@ public:
*/
virtual void Run() = 0;
};
class CoreExport Mutex
{
protected:
/* A mutex, used to keep threads in sync */
pthread_mutex_t mutex;
public:
/** Constructor
*/
Mutex();
/** Destructor
*/
~Mutex();
/** Attempt to lock the mutex, will hang until a lock can be achieved
*/
void Lock();
/** Unlock the mutex, it must be locked first
*/
void Unlock();
/** Attempt to lock the mutex, will return true on success and false on fail
* Does not block
* @return true or false
*/
bool TryLock();
};
class CoreExport Condition
: public Mutex
{
private:
/* A condition */
pthread_cond_t cond;
public:
/** Constructor
*/
Condition();
/** Destructor
*/
~Condition();
/** Called to wakeup the waiter
*/
void Wakeup();
/** Called to wait for a Wakeup() call
*/
void Wait();
};