Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// #region AsyncLockable
[AsyncLockable.lock](cancelable?: Cancelable) {
return this.lock(cancelable);
}
[AsyncLockable.unlock]() {
this.unlock();
}
// #endregion AsyncLockable
}
const disposablePrototype: object = Object.getPrototypeOf(Disposable.create(() => {}));
const mutexLockHandlePrototype: object = {
[AsyncLockable.lock](this: LockHandle, cancelable?: Cancelable) {
return this.lock(cancelable);
},
[AsyncLockable.unlock](this: LockHandle) {
return this.unlock();
},
[Disposable.dispose](this: LockHandle) {
if (this.ownsLock) {
this.unlock();
}
}
};
defineTag(mutexLockHandlePrototype, "MutexLockHandle");
Object.setPrototypeOf(mutexLockHandlePrototype, disposablePrototype);
function createLockHandle(mutex: AsyncMutex): LockHandle {
private _unlock(handle: LockHandle) {
if (this._handle !== handle) {
throw new Error("Lock already released.");
}
if (!this._waiters.resolveOne()) {
this._handle = undefined;
}
}
// #region AsyncLockable
[AsyncLockable.lock](cancelable?: Cancelable) {
return this.lock(cancelable);
}
[AsyncLockable.unlock]() {
this.unlock();
}
// #endregion AsyncLockable
}
const disposablePrototype: object = Object.getPrototypeOf(Disposable.create(() => {}));
const mutexLockHandlePrototype: object = {
[AsyncLockable.lock](this: LockHandle, cancelable?: Cancelable) {
return this.lock(cancelable);
},
[AsyncLockable.unlock](this: LockHandle) {
return this.unlock();
},
[Disposable.dispose](this: LockHandle) {
if (this.ownsLock) {
import { Tag, defineTag } from "@esfx/internal-tag";
import { WaitQueue } from "@esfx/async-waitqueue";
import { LockHandle, UpgradeableLockHandle, AsyncLockable } from "@esfx/async-lockable";
import { Cancelable } from "@esfx/cancelable";
import { Disposable } from "@esfx/disposable";
export { LockHandle, UpgradeableLockHandle } from "@esfx/async-lockable";
const disposablePrototype: object = Object.getPrototypeOf(Disposable.create(() => { }));
const lockHandlePrototype: object = {
get mutex() {
return this;
},
async [AsyncLockable.lock](this: LockHandle, cancelable?: Cancelable) {
await this.lock(cancelable);
return this;
},
[AsyncLockable.unlock](this: LockHandle) {
this.unlock();
},
[Disposable.dispose](this: LockHandle) {
if (this.ownsLock) {
this.unlock();
}
}
};
defineTag(lockHandlePrototype, "LockHandle");
Object.setPrototypeOf(lockHandlePrototype, disposablePrototype);
import { Cancelable } from "@esfx/cancelable";
import { Disposable } from "@esfx/disposable";
export { LockHandle, UpgradeableLockHandle } from "@esfx/async-lockable";
const disposablePrototype: object = Object.getPrototypeOf(Disposable.create(() => { }));
const lockHandlePrototype: object = {
get mutex() {
return this;
},
async [AsyncLockable.lock](this: LockHandle, cancelable?: Cancelable) {
await this.lock(cancelable);
return this;
},
[AsyncLockable.unlock](this: LockHandle) {
this.unlock();
},
[Disposable.dispose](this: LockHandle) {
if (this.ownsLock) {
this.unlock();
}
}
};
defineTag(lockHandlePrototype, "LockHandle");
Object.setPrototypeOf(lockHandlePrototype, disposablePrototype);
const readerPrototype: object = {};
defineTag(readerPrototype, "AsyncReaderWriterLockReader");
Object.setPrototypeOf(readerPrototype, lockHandlePrototype);