DEV Community

邱敬幃 Pardn Chiu
邱敬幃 Pardn Chiu

Posted on

Priority-based queue with automatic timeout promotion

cover


Core Features

Bounded Concurrency

Configurable worker pool size (default: CPU cores × 2). Tasks beyond worker capacity queue up to avoid system overload while maximizing hardware utilization.

Priority Queue and Promotion

A five-level priority system implemented with a min-heap (Immediate > High > Retry > Normal > Low). Higher-priority tasks execute first; tasks with the same priority are processed FIFO.
Tasks that wait for a long time are automatically promoted to a higher priority to prevent starvation. Promotion thresholds are calculated based on configured timeouts.

Error Retry

When a task fails, it can be automatically retried. Retry tasks are re-enqueued with Retry priority, which is between High and Normal, providing a delayed retry effect.


©️ 2025 邱敬幃 Pardn Chiu

Top comments (0)