summaryrefslogtreecommitdiff
path: root/core/os/rw_lock.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /core/os/rw_lock.h
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
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 6b4af83bf9..6d3079df51 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