Thread.cpp refinement

Hide thread mutex
Safe notify() method
Other refactoring
This commit is contained in:
Nekotekina 2016-09-07 01:38:52 +03:00
parent da878c36bd
commit a5a2d43d7c
35 changed files with 532 additions and 591 deletions

View file

@ -99,27 +99,39 @@ public:
}
};
// Simplified shared (reader) lock implementation, std::shared_lock compatible.
// Simplified shared (reader) lock implementation.
class reader_lock final
{
shared_mutex& m_mutex;
void lock()
{
m_mutex.lock_shared();
}
void unlock()
{
m_mutex.unlock_shared();
}
friend class cond_variable;
public:
reader_lock(const reader_lock&) = delete;
explicit reader_lock(shared_mutex& mutex)
: m_mutex(mutex)
{
m_mutex.lock_shared();
lock();
}
~reader_lock()
{
m_mutex.unlock_shared();
unlock();
}
};
// Simplified exclusive (writer) lock implementation, std::lock_guard compatible.
// Simplified exclusive (writer) lock implementation.
class writer_lock final
{
shared_mutex& m_mutex;