|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
418 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const semaphore = require('./semaphore.js');
|
|---|
| 6 |
|
|---|
| 7 | class Mutex {
|
|---|
| 8 | semaphore = new semaphore.Semaphore(1);
|
|---|
| 9 | get isLocked() {
|
|---|
| 10 | return this.semaphore.available === 0;
|
|---|
| 11 | }
|
|---|
| 12 | async acquire() {
|
|---|
| 13 | return this.semaphore.acquire();
|
|---|
| 14 | }
|
|---|
| 15 | release() {
|
|---|
| 16 | this.semaphore.release();
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | exports.Mutex = Mutex;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.