Skip to main content

Module concurrency

Module concurrency 

Source
Expand description

Concurrency limits and task execution helpers.

Limiter and PriorityLimiter provide FIFO and high-priority admission, with configurable wait timeouts and queue limits. Both return Permit, which can keep capacity held for a payload stream.

ConcurrencyLimiter caps the number of in-flight backend operations using a tokio semaphore. Each acquired ConcurrencyPermit notifies waiters on drop, allowing ConcurrencyLimiter::wait_all to resolve once all permits have been returned.

run_metered runs an isolated task and waits for its result, while spawn_metered starts the same task without waiting. Both provide panic recovery and service.task.* metric emission.

Structs§

ConcurrencyLimiter
Limits concurrent backend operations and tracks in-flight count.
ConcurrencyPermit
RAII guard for a concurrency permit.
Limiter
Limits concurrent operations with FIFO queuing and a configurable wait timeout.
LimiterStats
Snapshot of permits in use by a simple limiter.
Permit
Owned permit, released on drop.
PriorityLimiter
Limits concurrent operations with high-priority admission and FIFO within each priority.
PriorityLimiterStats
Snapshot of permits in use and queued acquisitions by priority.
Stats
Snapshot of concurrency limiter state.

Enums§

Priority
Priority for an acquisition from PriorityLimiter.

Functions§

run_metered
Runs a future on a dedicated task with panic isolation and timing metrics.
spawn_metered
Spawns a metered future without waiting for its result.