arbiter-worker-0.1.0.0
arbiter-worker
Safe HaskellNone
LanguageGHC2024

Arbiter.Worker.WorkQueue

Description

Internal to the arbiter packages. Not covered by the PVP.

Batch queue with in-flight counts and a slot-availability signal.

Synopsis

Documentation

data WorkQueue aSource #

The channel, the batches queued on it, the batches a worker holds, and whether a slot freed since the dispatcher last looked.

newWorkQueue :: MonadIO m => m (WorkQueue a)Source #

An empty queue with no busy slots.

pushWork :: MonadUnliftIO m => WorkQueue a -> [a] -> m ()Source #

Enqueue in order.

popWork :: MonadUnliftIO m => WorkQueue a -> m aSource #

Take the next item and transfer its count from queued to busy without interruption.

finishWork :: WorkQueue a -> STM ()Source #

Free the busy slot a popWork took and signal the dispatcher.

awaitFinished :: WorkQueue a -> STM ()Source #

Block until a slot freed, consuming the signal.

queuedCount :: WorkQueue a -> STM IntSource #

Batches queued and not yet taken by a worker.

busyCount :: WorkQueue a -> STM IntSource #

Batches a worker holds.

inFlight :: WorkQueue a -> STM IntSource #

Batches queued or held by a worker.