(readLock: ReadLock, fiberId: FiberId.FiberId, adjustment: number)
| 140 | * Adjusts the number of read locks held by the specified fiber id. |
| 141 | */ |
| 142 | const adjustReadLock = (readLock: ReadLock, fiberId: FiberId.FiberId, adjustment: number): ReadLock => { |
| 143 | const total = readLock.readLocksHeld(fiberId) |
| 144 | const newTotal = total + adjustment |
| 145 | if (newTotal < 0) { |
| 146 | throw new Error( |
| 147 | "BUG - TReentrantLock.ReadLock.adjust - please report an issue at https://github.com/Effect-TS/effect/issues" |
| 148 | ) |
| 149 | } |
| 150 | if (newTotal === 0) { |
| 151 | return new ReadLock(HashMap.remove(readLock.readers, fiberId)) |
| 152 | } |
| 153 | return new ReadLock(HashMap.set(readLock.readers, fiberId, newTotal)) |
| 154 | } |
| 155 | |
| 156 | const adjustRead = (self: TReentrantLock.TReentrantLock, delta: number): STM.STM<number> => |
| 157 | core.withSTMRuntime((runtime) => { |
no test coverage detected