Luna::IReadWriteLock
Represents one system-level read write lock.
interface Luna::IReadWriteLock : public virtual Interface
One read write lock allows multiple threads to access the same resource in read mode, or at most one thread to access the resource in write mode. One read write lock is created in unlocked mode, and can be transferred to read mode by acquiring read ownership of the lock, or transferred to write mode by acquiring write ownership of the lock. When the read write lock is in read mode, successing acquires of read ownership succeeds, but acquires of write ownership will fail or be blocked until all read ownerships are released; When the read write lock is in write mode, all succeeding acquires of read and write ownerships will fail or be blocked until the write ownership is released. The write ownership is not recursive: succeeding acquire of write ownership from the thread that already acquired the write ownership causes deadlock and shall not be performed. This\ type\ is\ thread\ safe.
Base type
Member functions
-
Acquires one read ownership of the lock.
-
virtual void acquire_write()=0
Acquires one write ownership of the lock.
-
virtual bool try_acquire_read()=0
Tries to acquire one read ownership of the lock.
-
virtual bool try_acquire_write()=0
Tries to acquire one write ownership of the lock.
-
Releases the read ownership acquired by acquire_read or try_acquire_read.
-
virtual void release_write()=0
Releases the write ownership acquired by acquire_write or try_acquire_write.