extensible-effects-concurrent-0.16.1: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Api.Observer.Queue

Description

A small process to capture and _share_ observation's by enqueueing them into an STM TBQeueu.

Synopsis

Documentation

data ObservationQueue a Source #

Contains a TBQueue capturing observations received by enqueueObservationsRegistered or spawnLinkObserverationQueue.

Instances
data Api (ObservationQueue a) r Source #

Capture an observation.

Instance details

Defined in Control.Eff.Concurrent.Api.Observer.Queue

readObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, HasLogging IO r) => Eff r o Source #

Read queued observations captured and enqueued in the shared TBQueue by spawnLinkObserverationQueue. This blocks until something was captured or an interrupt or exceptions was thrown. For a non-blocking variant use tryReadObservationQueue or flushObservationQueue.

tryReadObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, HasLogging IO r) => Eff r (Maybe o) Source #

Read queued observations captured and enqueued in the shared TBQueue by spawnLinkObserverationQueue. Return the oldest enqueued observation immediately or Nothing if the queue is empty. Use readObservationQueue to block until an observation is observed.

flushObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, HasLogging IO r) => Eff r [o] Source #

Read at once all currently queued observations captured and enqueued in the shared TBQueue by spawnLinkObserverationQueue. This returns immediately all currently enqueued Observations. For a blocking variant use readObservationQueue.

spawnLinkObserverationQueue :: forall o q a. (Typeable o, Show o, HasLogging IO q, Lifted IO q, HasCallStack) => Server (ObserverRegistry o) -> Int -> Eff (ObservationQueueReader o ': InterruptableProcess q) a -> Eff (InterruptableProcess q) a Source #

Observe a Server that implements an Observable Api. The observations can be obtained by readObservationQueue. All observations are captured up to the queue size limit, such that the first message received will be first message returned by readObservationQueue.