summaryrefslogtreecommitdiffstats
path: root/src/threads/mutex.h
diff options
context:
space:
mode:
authorFrédéric Brière <fbriere@fbriere.net>2019-10-02 22:13:56 -0400
committerFrédéric Brière <fbriere@fbriere.net>2019-12-26 12:09:17 -0500
commit3d126cd9a7f9029e199e9220e2ffa08ac4e23227 (patch)
treefcb055a4439f1a1e87f8c83ef638c5db0d0788b0 /src/threads/mutex.h
parentb60354d82e3dc0e219cf08e956c94aa2585c104b (diff)
downloadtwinkle-3d126cd9a7f9029e199e9220e2ffa08ac4e23227.tar
twinkle-3d126cd9a7f9029e199e9220e2ffa08ac4e23227.tar.gz
twinkle-3d126cd9a7f9029e199e9220e2ffa08ac4e23227.tar.lz
twinkle-3d126cd9a7f9029e199e9220e2ffa08ac4e23227.tar.xz
twinkle-3d126cd9a7f9029e199e9220e2ffa08ac4e23227.zip
Create t_rwmutex_guard base class
(Doing this ahead of time to simplify the next commit a bit.)
Diffstat (limited to 'src/threads/mutex.h')
-rw-r--r--src/threads/mutex.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/threads/mutex.h b/src/threads/mutex.h
index 15d5181..d757d61 100644
--- a/src/threads/mutex.h
+++ b/src/threads/mutex.h
@@ -95,17 +95,22 @@ public:
void unlock();
};
-class t_rwmutex_reader {
-private:
+// Base (abstract) class
+class t_rwmutex_guard {
+protected:
t_rwmutex& _mutex;
+
+ // A protected constructor to keep this class abstract
+ t_rwmutex_guard(t_rwmutex& mutex);
+};
+
+class t_rwmutex_reader : public t_rwmutex_guard {
public:
t_rwmutex_reader(t_rwmutex& mutex);
~t_rwmutex_reader();
};
-class t_rwmutex_writer {
-private:
- t_rwmutex& _mutex;
+class t_rwmutex_writer : public t_rwmutex_guard {
public:
t_rwmutex_writer(t_rwmutex& mutex);
~t_rwmutex_writer();