skills/concurrency-patterns/SKILL.md
Implement thread-safe code, mutexes, semaphores, async/await patterns, and concurrent data structures. Use when handling parallel operations, race conditions, or building high-performance concurrent systems.
npx skillsauth add aj-geddes/useful-ai-prompts concurrency-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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) |
development
Implement Zero Trust security model with identity verification, microsegmentation, least privilege access, and continuous monitoring. Use when building secure cloud-native applications.
development
Prevent Cross-Site Scripting (XSS) attacks through input sanitization, output encoding, and Content Security Policy. Use when handling user-generated content in web applications.
tools
Create wireframes and interactive prototypes to visualize user interfaces and gather feedback early. Use tools and techniques to communicate design ideas before development.
development
Implement real-time bidirectional communication with WebSockets including connection management, message routing, and scaling. Use when building real-time features, chat systems, live notifications, or collaborative applications.