5 * - Reader-Writer Mutex (Multiple Readers, One Writer)
12 typedef struct sRWLock tRWLock;
16 tShortSpinlock Protector; //!< Protector for the lock strucure
17 const char *Name; //!< Human-readable name
18 int Level; // Number of readers active
19 struct sThread *volatile Owner; //!< Owner of the lock (set upon getting the lock)
20 struct sThread *ReaderWaiting; //!< Waiting threads (readers)
21 struct sThread *ReaderWaitingLast; //!< Waiting threads
23 struct sThread *WriterWaiting; //!< Waiting threads (writers)
24 struct sThread *WriterWaitingLast; //!< Waiting threads
28 * \brief Acquire a read-write lock for reading
29 * \param Lock Lock to acquire
30 * \return zero on success, -1 if terminated
32 * Waits until the lock is readable and the increments the reader count
34 extern int RWLock_AcquireRead(tRWLock *Lock);
37 * \brief Acquire a read-write lock for writing
38 * \param Lock Lock to acquire
39 * \return zero on success, -1 if terminated
41 * Waits until there are no writers, flags all readers to wait, then acquires the lock.
43 extern int RWLock_AcquireWrite(tRWLock *Lock);
46 * \brief Release a held rw lock
47 * \param Lock Lock to release
48 * \note Releasing a non-held lock has no effect
50 extern void RWLock_Release(tRWLock *Lock);