Skip to content

Instantly share code, notes, and snippets.

View PandaWorker's full-sized avatar

Panda PandaWorker

View GitHub Profile
@PandaWorker
PandaWorker / CoreMutex.ts
Created August 14, 2024 13:14
perfomance
export class Mutex {
#waiters: Set<Promise<void>> = new Set();
/**
* Returns true if the mutex is locked, false otherwise.
*/
get locked(): boolean {
return this.#waiters.size > 0;
}