source: node_modules/es-toolkit/dist/promise/mutex.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 314 bytes
Line 
1import { Semaphore } from './semaphore.mjs';
2
3class Mutex {
4 semaphore = new Semaphore(1);
5 get isLocked() {
6 return this.semaphore.available === 0;
7 }
8 async acquire() {
9 return this.semaphore.acquire();
10 }
11 release() {
12 this.semaphore.release();
13 }
14}
15
16export { Mutex };
Note: See TracBrowser for help on using the repository browser.