From aj-geddes-useful-ai-prompts-4
Implements concurrency patterns like mutexes, semaphores, promise pools, worker pools, and async structures in TypeScript, Node.js, Python. Handles parallel ops, race conditions, high-perf systems.
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4This skill uses the workspace's default tool permissions.
- [Overview](#overview)
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Implement safe concurrent code using proper synchronization primitives and patterns for parallel execution.
Minimal working example:
class PromisePool {
private queue: Array<() => Promise<any>> = [];
private active = 0;
constructor(private concurrency: number) {}
async add<T>(fn: () => Promise<T>): Promise<T> {
while (this.active >= this.concurrency) {
await this.waitForSlot();
}
this.active++;
try {
return await fn();
} finally {
this.active--;
}
}
private async waitForSlot(): Promise<void> {
return new Promise((resolve) => {
const checkSlot = () => {
if (this.active < this.concurrency) {
resolve();
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Promise Pool (TypeScript) | Promise Pool (TypeScript) |
| Mutex and Semaphore (TypeScript) | Mutex and Semaphore (TypeScript) |
| Worker Pool (Node.js) | Worker Pool (Node.js) |
| Python Threading Patterns | Python Threading Patterns |
| Async Patterns (Python asyncio) | Async Patterns (Python asyncio) |
| Go-Style Channels (Simulation) | Go-Style Channels (Simulation) |