aboutsummaryrefslogtreecommitdiff
path: root/core/os/rw_lock.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/os/rw_lock.h')
-rw-r--r--core/os/rw_lock.h42
1 files changed, 24 insertions, 18 deletions
diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h
index 6b4af83bf..6d3079df5 100644
--- a/core/os/rw_lock.h
+++ b/core/os/rw_lock.h
@@ -33,42 +33,48 @@
class RWLock {
protected:
- static RWLock* (*create_func)();
+ static RWLock *(*create_func)();
public:
+ virtual void read_lock() = 0; ///< Lock the rwlock, block if locked by someone else
+ virtual void read_unlock() = 0; ///< Unlock the rwlock, let other threads continue
+ virtual Error read_try_lock() = 0; ///< Attempt to lock the rwlock, OK on success, ERROR means it can't lock.
- virtual void read_lock()=0; ///< Lock the rwlock, block if locked by someone else
- virtual void read_unlock()=0; ///< Unlock the rwlock, let other threads continue
- virtual Error read_try_lock()=0; ///< Attempt to lock the rwlock, OK on success, ERROR means it can't lock.
+ virtual void write_lock() = 0; ///< Lock the rwlock, block if locked by someone else
+ virtual void write_unlock() = 0; ///< Unlock the rwlock, let other thwrites continue
+ virtual Error write_try_lock() = 0; ///< Attempt to lock the rwlock, OK on success, ERROR means it can't lock.
- virtual void write_lock()=0; ///< Lock the rwlock, block if locked by someone else
- virtual void write_unlock()=0; ///< Unlock the rwlock, let other thwrites continue
- virtual Error write_try_lock()=0; ///< Attempt to lock the rwlock, OK on success, ERROR means it can't lock.
-
- static RWLock * create(); ///< Create a rwlock
+ static RWLock *create(); ///< Create a rwlock
virtual ~RWLock();
};
-
class RWLockRead {
RWLock *lock;
-public:
-
- RWLockRead(RWLock* p_lock) { lock=p_lock; if (lock) lock->read_lock(); }
- ~RWLockRead() { if (lock) lock->read_unlock(); }
+public:
+ RWLockRead(RWLock *p_lock) {
+ lock = p_lock;
+ if (lock) lock->read_lock();
+ }
+ ~RWLockRead() {
+ if (lock) lock->read_unlock();
+ }
};
class RWLockWrite {
RWLock *lock;
-public:
-
- RWLockWrite(RWLock* p_lock) { lock=p_lock; if (lock) lock->write_lock(); }
- ~RWLockWrite() { if (lock) lock->write_unlock(); }
+public:
+ RWLockWrite(RWLock *p_lock) {
+ lock = p_lock;
+ if (lock) lock->write_lock();
+ }
+ ~RWLockWrite() {
+ if (lock) lock->write_unlock();
+ }
};
#endif // RWLOCK_H