| 41 | } |
| 42 | |
| 43 | void ReadWriteLock::ReleaseWriteUnlock() { |
| 44 | //decrement waiting and active writers |
| 45 | std::unique_lock<std::mutex> lk(shared); |
| 46 | waiting_writers--; |
| 47 | active_writers--; |
| 48 | if (waiting_writers > 0) { |
| 49 | writer_gate.notify_one(); //(priority to writers) |
| 50 | } else { |
| 51 | reader_gate.notify_all(); //notify readers |
| 52 | } |
| 53 | lk.unlock(); |
| 54 | } |
| 55 |