| 30 | } |
| 31 | |
| 32 | void ReadWriteLock::AquireWriteLock() { |
| 33 | //declare waiting and wait till there are no more active readers or writers and get lock |
| 34 | std::unique_lock<std::mutex> lk(shared); |
| 35 | waiting_writers++; |
| 36 | while ( active_readers != 0 || active_writers != 0 ) { //if any is active wait for them to finish |
| 37 | writer_gate.wait(lk); |
| 38 | } |
| 39 | active_writers++; |
| 40 | lk.unlock(); |
| 41 | } |
| 42 | |
| 43 | void ReadWriteLock::ReleaseWriteUnlock() { |
| 44 | //decrement waiting and active writers |