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

System.ThreadManager

Description

A thread manager including a time manager. The manager has responsibility to kill managed threads.

Synopsis

Documentation

data ThreadManager Source #

Manager to manage the thread and the timer.

newThreadManager :: Manager -> IO ThreadManager Source #

Starting a thread manager. Its action is initially set to 'return ()' and should be set by setAction. This allows that the action can include the manager itself.

stopAfter :: ThreadManager -> IO a -> (Maybe SomeException -> IO ()) -> IO a Source #

Stopping the manager.

The action is run in the scope of an exception handler that catches all exceptions (including asynchronous ones); this allows the cleanup handler to cleanup in all circumstances. If an exception is caught, it is rethrown after the cleanup is complete.

Fork

forkManaged Source #

Arguments

:: ThreadManager 
-> String

Thread name

-> IO ()

Action

-> IO () 

Fork a managed thread.

This guarantees that the thread ID is added to the manager's queue before the thread starts, and is removed again when the thread terminates (normally or abnormally).

forkManagedFinally :: ThreadManager -> String -> IO () -> IO () -> IO () Source #

Fork a managed thread with a cleanup function.

forkManagedUnmask :: ThreadManager -> String -> ((forall x. IO x -> IO x) -> IO ()) -> IO () Source #

Like forkManaged, but run action with exceptions masked

forkManagedTimeout :: ThreadManager -> String -> (Handle -> IO ()) -> IO () Source #

Fork a managed thread with a handle created by a timeout manager.

forkManagedTimeoutFinally :: ThreadManager -> String -> (Handle -> IO ()) -> IO () -> IO () Source #

Fork a managed thread with a handle created by a timeout manager and with a cleanup function.

Synchronization

waitUntilAllGone :: ThreadManager -> IO () Source #

Wait until all managed thread are finished.

Re-exports

data Manager Source #

A timeout manager

data Handle Source #

A handle used by a timeout manager.

tickle :: Handle -> IO () Source #

Setting the state to active. Manager turns active to inactive repeatedly.

pause :: Handle -> IO () Source #

Setting the state to paused. Manager does not change the value.

resume :: Handle -> IO () Source #

Setting the paused state to active. This is an alias to tickle.