src: added ReaderWriterLock, helpers and Semaphore

This commit is contained in:
malte_langkabel
2016-10-10 17:37:38 +02:00
parent 072cccf852
commit 86f652d221
10 changed files with 199 additions and 2 deletions
@@ -0,0 +1,30 @@
#ifndef READER_WRITER_LOCK_H
#define READER_WRITER_LOCK_H
#include <mutex>
#include "Semaphore.h"
class ReaderWriterLock
{
public:
ReaderWriterLock();
private:
ReaderWriterLock(const ReaderWriterLock &lock);
public:
~ReaderWriterLock();
void readerLock();
void readerUnlock();
void writerLock();
void writerUnlock();
private:
int m_readerCount;
std::mutex m_readerCountMutex;
Semaphore m_allowedReaders, m_allowedWriters;
};
#endif // READER_WRITER_LOCK_H