timers-0.1.0.1: Simple package that implements timers.

Safe HaskellSafe-Infered

Control.Concurrent.Timer.Lifted

Synopsis

Documentation

data Timer m Source

The data type representing the timer. For now, the action and delay are fixed for the lifetime of the Timer.

type TimerIO = Timer IOSource

Utility

oneShotTimerSource

Arguments

:: MonadBaseControl IO m 
=> Delay

The (minimal) time until the execution in microseconds.

-> m ()

The action to be executed.

-> m (Timer m) 

Executes the the given action once after the given delay elapsed, no sooner, maybe later.

oneShotRestart :: MonadBaseControl IO m => Timer m -> m BoolSource

Attempts to restart (or start) a timer making it a one shot timer.

Returns True if the restrat was successful, otherwise (e.g. other thread is attempting to restart the timer) returns False.

repeatedTimerSource

Arguments

:: MonadBaseControl IO m 
=> Delay

The (minimal) delay between executions.

-> m ()

The action to be executed.

-> m (Timer m) 

Executes the the given action repeatedly with at least the given delay between executions.

repeatedRestart :: MonadBaseControl IO m => Timer m -> m BoolSource

Attempts to restart (or start) a timer making it a repeated timer.

Returns True if the restrat was successful, otherwise (e.g. other thread is attempting to restart the timer) returns False.

newTimerSource

Arguments

:: MonadBase IO m 
=> Delay

The (minimal) delay between executions.

-> m ()

The action to be executed.

-> m (Timer m) 

Creates a new timer. This does not start the timer.

stopTimer :: MonadBaseControl IO m => Timer m -> m ()Source

This function is blocking. It waits until it can stop the timer (until there is a value in the threadID MVar), then it kill the thread.