MCPcopy Create free account
hub / github.com/arctic-cli/interface / read

Function read

packages/arctic/src/util/lock.ts:47–71  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

45 }
46
47 export async function read(key: string): Promise<Disposable> {
48 const lock = get(key)
49
50 return new Promise((resolve) => {
51 if (!lock.writer && lock.waitingWriters.length === 0) {
52 lock.readers++
53 resolve({
54 [Symbol.dispose]: () => {
55 lock.readers--
56 process(key)
57 },
58 })
59 } else {
60 lock.waitingReaders.push(() => {
61 lock.readers++
62 resolve({
63 [Symbol.dispose]: () => {
64 lock.readers--
65 process(key)
66 },
67 })
68 })
69 }
70 })
71 }
72
73 export async function write(key: string): Promise<Disposable> {
74 const lock = get(key)

Callers

nothing calls this directly

Calls 4

resolveFunction · 0.85
pushMethod · 0.80
getFunction · 0.70
processFunction · 0.70

Tested by

no test coverage detected