GitHub

partitioned_semaphore

API reference for partitioned_semaphore.

PartitionedSemaphore[K]: one pool of permits shared fairly by keys.

Waiters are grouped by key, and freed permits go round-robin across keys, one permit per turn, so a key with many waiters cannot starve the others. A waiter that needs several permits collects them as they come and is woken once it has them all. Only the wait is interruptible: an interrupt at any point before the permits are guarded gives back what the waiter collected.

A request for more permits than the capacity never completes, as in Effect.

Classes