1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-04-29 07:32:17 +00:00

15 lines
289 B
JavaScript
Raw Normal View History

export class Lock {
constructor() {
this.lockHolder = null;
}
async withLock(scope) {
while (this.lockHolder !== null) {
await this.lockHolder;
}
this.lockHolder = Promise.resolve(null).then(scope);
await this.lockHolder;
this.lockHolder = null;
}
}