2013-11-26 21:51:40 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Dennis Andersen] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-11-26 21:08:34 +01:00
|
|
|
#ifndef MISC_OYSTER_MUTEX_H
|
|
|
|
#define MISC_OYSTER_MUTEX_H
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <thread>
|
|
|
|
#include <atomic>
|
|
|
|
|
2013-11-28 15:17:25 +01:00
|
|
|
class OysterMutex
|
2013-11-26 21:08:34 +01:00
|
|
|
{
|
2013-11-28 15:17:25 +01:00
|
|
|
public:
|
|
|
|
OysterMutex();
|
|
|
|
OysterMutex(bool initialOwnership);
|
|
|
|
virtual~OysterMutex();
|
|
|
|
void LockMutex();
|
|
|
|
void LockMutex(unsigned int timeSpan);
|
|
|
|
void UnlockMutex();
|
|
|
|
/** Returns true if mutex is taken */
|
|
|
|
bool IsTaken();
|
2013-11-26 21:08:34 +01:00
|
|
|
|
2013-11-28 15:17:25 +01:00
|
|
|
private:
|
|
|
|
std::mutex mutex;
|
|
|
|
std::thread::id id;
|
2013-11-26 21:08:34 +01:00
|
|
|
|
2013-11-28 15:17:25 +01:00
|
|
|
OysterMutex(const OysterMutex&);
|
|
|
|
};
|
2013-11-26 21:08:34 +01:00
|
|
|
|
|
|
|
#endif // !MISC_OYSTER_MUTEX_H
|