Safe Haskell | None |
---|---|
Language | Haskell2010 |
A small process to capture and _share_ observation's by enqueueing them into an STM TBQeueu
.
Synopsis
- data ObservationQueue a
- type ObservationQueueReader a = Reader (ObservationQueue a)
- readObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, HasLogging IO r) => Eff r o
- tryReadObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, HasLogging IO r) => Eff r (Maybe o)
- flushObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, HasLogging IO r) => Eff r [o]
- spawnLinkObservationQueue :: 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
Documentation
data ObservationQueue a Source #
Contains a TBQueue
capturing observations received by enqueueObservationsRegistered
or spawnLinkObservationQueue
.
Instances
data Api (ObservationQueue a) r Source # | Capture an observation. |
Defined in Control.Eff.Concurrent.Api.Observer.Queue data Api (ObservationQueue a) r where
|
type ObservationQueueReader a = Reader (ObservationQueue a) Source #
A Reader
for an ObservationQueue
.
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 spawnLinkObservationQueue
.
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 spawnLinkObservationQueue
.
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 spawnLinkObservationQueue
.
This returns immediately all currently enqueued Observation
s. For a blocking
variant use readObservationQueue
.
spawnLinkObservationQueue :: 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
.