| 70 | } |
| 71 | |
| 72 | void RWMutex::lockWriter() { |
| 73 | std::unique_lock<std::mutex> lock(mutex); |
| 74 | if (readLocks > 0) { |
| 75 | pendingWriteLocks++; |
| 76 | cv.wait(lock, [&] { return readLocks == 0; }); |
| 77 | pendingWriteLocks--; |
| 78 | } |
| 79 | lock.release(); // Keep lock held |
| 80 | } |
| 81 | |
| 82 | void RWMutex::unlockWriter() { |
| 83 | if (pendingWriteLocks > 0) { |