| 123 | return false; |
| 124 | } |
| 125 | bool tryBeginWrite(const char* aReason) |
| 126 | { |
| 127 | if (lock.value()) |
| 128 | return false; |
| 129 | if (lock.exchangeAdd(-LOCK_WRITER_OFFSET) == 0) |
| 130 | { |
| 131 | reason(aReason); |
| 132 | return true; |
| 133 | } |
| 134 | // We stepped on somebody's toes. Fix our mistake |
| 135 | if (lock.exchangeAdd(LOCK_WRITER_OFFSET) == -LOCK_WRITER_OFFSET) |
| 136 | unblockWaiting(); |
| 137 | return false; |
| 138 | } |
| 139 | void beginRead(const char* aReason) |
| 140 | { |
| 141 | if (!tryBeginRead(aReason)) |
no test coverage detected