timers-0.1.0.1: Simple package that implements timers.

Safe HaskellSafe-Infered

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 IOSource

Utility

oneShotTimerSource

Arguments

:: Delay

The (minimal) time until the execution in microseconds.

-> IO ()

The action to be executed.

-> IO TimerIO 

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

oneShotRestart :: TimerIO -> IO 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

:: Delay

The (minimal) delay between executions.

-> IO ()

The action to be executed.

-> IO TimerIO 

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

repeatedRestart :: TimerIO -> IO 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

:: Delay

The (minimal) delay between executions.

-> IO ()

The action to be executed.

-> IO TimerIO 

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 threadID MVar), then it kill the thread.