MCPcopy Create free account
hub / github.com/MultithreadedJSBook/code-samples / constructor

Method constructor

ch6-mutex/mutex.js:9–12  ·  view source on GitHub ↗
(shared, index)

Source from the content-addressed store, hash-verified

7
8class Mutex {
9 constructor(shared, index) {
10 this.shared = shared;
11 this.index = index;
12 }
13
14 acquire() {
15 if (compareExchange(this.shared, this.index, UNLOCKED, LOCKED) === UNLOCKED) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected