timers-0.2.0.4: Simple package that implements timers.

Safe HaskellSafe
LanguageHaskell2010

Control.Concurrent.Timer

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 IO Source #

Utility

oneShotTimer Source #

Arguments

:: IO ()

The action to be executed.

-> Delay

The (minimal) time until the execution in microseconds.

-> IO TimerIO 

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

oneShotStart Source #

Arguments

:: TimerIO 
-> IO ()

The action the timer will start with.

-> Delay

The delay the timer will start with.

-> IO Bool 

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

If the timer was initialized before it will be stopped (killed) and started anew.

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

oneShotRestart :: TimerIO -> IO Bool Source #

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

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

repeatedTimer Source #

Arguments

:: IO ()

The action to be executed.

-> Delay

The (minimal) delay between executions.

-> IO TimerIO 

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

repeatedStart Source #

Arguments

:: TimerIO 
-> IO ()

The action the timer will start with.

-> Delay

The delay the timer will start with.

-> IO Bool 

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

If the timer was initialized before it will be stopped (killed) and started anew.

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

repeatedRestart :: TimerIO -> IO Bool Source #

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

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

newTimer :: IO TimerIO Source #

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

stopTimer :: TimerIO -> IO () 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).