prodapi-0.1.0.0: Some curated and opinionated packages for building Haskell services.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Prod.Background

Synopsis

Documentation

data BackgroundVal a Source #

A value that is coupled to an async in charge of updating the value.

Instances

Instances details
Functor BackgroundVal Source # 
Instance details

Defined in Prod.Background

Methods

fmap :: (a -> b) -> BackgroundVal a -> BackgroundVal b #

(<$) :: a -> BackgroundVal b -> BackgroundVal a #

type MicroSeconds n = n Source #

Fantom type for annotating Int.

background Source #

Arguments

:: Tracer IO (Track a) 
-> b

initial state

-> a

initial value

-> (b -> IO (a, b))

state-influenced task

-> IO (BackgroundVal a) 

Starts a background task continuously updating a value.

backgroundLoop Source #

Arguments

:: Tracer IO (Track a) 
-> a

initial value

-> IO a

periodic task

-> MicroSeconds Int

wait period between two executions

-> IO (BackgroundVal a) 

Starts a background task continuously updating a value at a periodic interval. This is implemented by interspersing a threadDelay before the task and calling background and hiding the 'state-passing' arguments.

kill :: (HasCallStack, MonadIO m) => BackgroundVal a -> m () Source #

Kills the watchdog by killing the underlying async.

readBackgroundVal :: MonadIO m => BackgroundVal a -> m a Source #

Kills the watchdog by killing the underlying async.

data Track r Source #

Constructors

Init r 
RunStart 
RunDone r r 
Kill CallStack 

Instances

Instances details
Functor Track Source # 
Instance details

Defined in Prod.Background

Methods

fmap :: (a -> b) -> Track a -> Track b #

(<$) :: a -> Track b -> Track a #

Show r => Show (Track r) Source # 
Instance details

Defined in Prod.Background

Methods

showsPrec :: Int -> Track r -> ShowS #

show :: Track r -> String #

showList :: [Track r] -> ShowS #