Skip to main content
Glama
by OpaqueGlass
mutex.ts926 B
export default class Mutex { private isLocked: boolean = false; private queue: (() => void)[] = []; async lock(): Promise<void> { return new Promise<void>((resolve) => { const acquireLock = async () => { if (!this.isLocked) { this.isLocked = true; resolve(); } else { this.queue.push(() => { this.isLocked = true; resolve(); }); } }; acquireLock(); }); } tryLock(): boolean { if (!this.isLocked) { this.isLocked = true; return true; } else { return false; } } unlock(): void { this.isLocked = false; const next = this.queue.shift(); if (next) { next(); } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OpaqueGlass/syplugin-anMCPServer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server