| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Concurrent.Async.Timer
- data Timer
- defaultTimerConf :: TimerConf
- timerConfSetInitDelay :: Int -> TimerConf -> TimerConf
- timerConfSetInterval :: Int -> TimerConf -> TimerConf
- withAsyncTimer :: (MonadBaseControl IO m, MonadMask m, Forall (Pure m)) => TimerConf -> (Timer -> m b) -> m b
- timerWait :: MonadBaseControl IO m => Timer -> m ()
Documentation
This is the type of timer handle, which will be provided to the
IO action to be executed within withAsyncTimer. The user can use
timerWait on this timer to delay execution until the next timer
synchronization event.
defaultTimerConf :: TimerConf #
Default timer configuration specifies no initial delay and an interval delay of 1s.
timerConfSetInitDelay :: Int -> TimerConf -> TimerConf #
Set the initial delay in the provided timer configuration.
timerConfSetInterval :: Int -> TimerConf -> TimerConf #
Set the interval delay in the provided timer configuration.
withAsyncTimer :: (MonadBaseControl IO m, MonadMask m, Forall (Pure m)) => TimerConf -> (Timer -> m b) -> m b #
Spawn a timer thread based on the provided timer configuration
and then run the provided IO action, which receives the new timer
as an argument and call timerWait on it for synchronization. When
the provided IO action has terminated, the timer thread will be
terminated also.
This functions requires the contraint , which
means that the monad Forall (Pure m)m needs to satisfy for all
StM m a ~ aa.
timerWait :: MonadBaseControl IO m => Timer -> m () #
Wait for the next synchronization event on the givem timer.