time-manager-0.3.0: Scalable timer
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.TimeManager

Description

Timeout manager. Since v0.3.0, timeout manager is a wrapper of GHC System TimerManager.

Users of old version should check the current semantics.

Synopsis

Types

data Manager Source #

A timeout manager

defaultManager :: Manager Source #

A manager whose timeout value is 0 (no callbacks are fired).

type TimeoutAction = IO () Source #

An action (callback) to be performed on timeout.

data Handle Source #

A handle used by a timeout manager.

Manager

initialize :: Int -> IO Manager Source #

Creating timeout manager with a timeout value in microseconds.

Setting the timeout to zero or lower (<= 0) will produce a defaultManager.

stopManager :: Manager -> IO () Source #

Deprecated: This function does nothing since version 0.3.0

Obsoleted since version 0.3.0 Is now equivalent to pure ().

killManager :: Manager -> IO () Source #

Deprecated: This function does nothing since version 0.3.0

Obsoleted since version 0.3.0 Is now equivalent to pure ().

withManager Source #

Arguments

:: Int

timeout in microseconds

-> (Manager -> IO a) 
-> IO a 

Call the inner function with a timeout manager.

withManager' Source #

Arguments

:: Int

timeout in microseconds

-> (Manager -> IO a) 
-> IO a 

Deprecated: This function is the same as withManager since version 0.3.0

Call the inner function with a timeout manager. This is identical to withManager.

Registering a timeout action

withHandle :: Manager -> TimeoutAction -> (Handle -> IO a) -> IO a Source #

Registering a timeout action and unregister its handle when the body action is finished.

withHandleKillThread :: Manager -> TimeoutAction -> (Handle -> IO ()) -> IO () Source #

Registering a timeout action of killing this thread and unregister its handle when the body action is killed or finished.

Control timeout

tickle :: Handle -> IO () Source #

Extending the timeout.

pause :: Handle -> IO () Source #

This is identical to cancel. To resume timeout with the same Handle, resume MUST be called. Don't call tickle for resumption.

resume :: Handle -> IO () Source #

Resuming the timeout.

Low level

register :: Manager -> TimeoutAction -> IO Handle Source #

Registering a timeout action.

registerKillThread :: Manager -> TimeoutAction -> IO Handle Source #

Registering a timeout action of killing this thread. TimeoutThread is thrown to the thread which called this function on timeout. Catch TimeoutThread if you don't want to leak the asynchronous exception to GHC RTS.

cancel :: Handle -> IO () Source #

Unregistering the timeout.

Exceptions

data TimeoutThread Source #

The asynchronous exception thrown if a thread is registered via registerKillThread.

Constructors

TimeoutThread