timers-0.2.0.1: Simple package that implements timers.

Safe HaskellNone

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 
=> m ()

The action to be executed.

-> Delay

The (minimal) time until the execution in microseconds.

-> m (Timer m) 

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

oneShotStartSource

Arguments

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

The action the timer will start with.

-> Delay

The dealy the timer will start with.

-> m Bool 

Attempts to start a timer. The started timer will have the given delay and action associated and will be one-shot timer.

If the timer was already initialized, it the previous timer will be stoped (the thread killed) and the timer will be started anew.

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

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

Attempts to restart already initialized timer. The restarted timer will have the same delay and action associated and will be one-shot timer.

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

repeatedTimerSource

Arguments

:: MonadBaseControl IO m 
=> m ()

The action to be executed.

-> Delay

The (minimal) delay between executions.

-> m (Timer m) 

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

repeatedStartSource

Arguments

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

The action the timer will start with.

-> Delay

The dealy the timer will start with.

-> m Bool 

Attempts to start a timer. The started timer will have the given delay and action associated and will be repeated timer.

If the timer was already initialized, it the previous timer will be stoped (the thread killed) and the timer will be started anew.

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

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

Attempts to restart already initialized timer. The restarted timer will have the same delay and action associated and will be one-shot timer.

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

newTimer :: MonadBase IO m => m (Timer m)Source

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 MVar), then it kills the timer's thread.

After this action completes, the Timer is not innitialized anymore (the MVar contains Nothing).