()
| 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) { |