MCPcopy Index your code
hub / github.com/Effect-TS/effect / adjustReadLock

Function adjustReadLock

packages/effect/src/internal/stm/tReentrantLock.ts:142–154  ·  view source on GitHub ↗
(readLock: ReadLock, fiberId: FiberId.FiberId, adjustment: number)

Source from the content-addressed store, hash-verified

140 * Adjusts the number of read locks held by the specified fiber id.
141 */
142const 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
156const adjustRead = (self: TReentrantLock.TReentrantLock, delta: number): STM.STM<number> =>
157 core.withSTMRuntime((runtime) => {

Callers 1

adjustReadFunction · 0.85

Calls 3

readLocksHeldMethod · 0.65
removeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected