-- | An effect for {en,de}queueing tasks of a particular type
-- through concurrent channels.
-- | Schedule work through a task queue.
data TaskQueue work :: Effect where
Enqueue :: work -> TaskQueue work m ()
Dequeue :: TaskQueue work m work
makeEffect ''TaskQueue
runTaskQueue
:: forall task es a.
(Concurrent :> es)
=> Eff (TaskQueue task : es) a
-> Eff es a
runTaskQueue eff = do
chan <- newChan
interpret (run chan) eff
where
\case
Enqueue v -> writeChan chan v
Dequeue -> readChan chan
data PerformTask
= PerformTask (AS.Activity AS.Object) Channel
data DeliverTask
= DeliverTask (AS.Activity AS.Object) Channel