MCPcopy Index your code
hub / github.com/MultithreadedJSBook/code-samples / acquire

Method acquire

ch6-mutex/mutex.js:14–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12 }
13
14 acquire() {
15 if (compareExchange(this.shared, this.index, UNLOCKED, LOCKED) === UNLOCKED) {
16 return;
17 }
18 wait(this.shared, this.index, LOCKED);
19 this.acquire();
20 }
21
22 release() {
23 if (compareExchange(this.shared, this.index, LOCKED, UNLOCKED) !== LOCKED) {

Callers 1

execMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected