Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A thread manager including a time manager. The manager has responsibility to kill managed threads.
Synopsis
- data ThreadManager
- newThreadManager :: Manager -> IO ThreadManager
- stopAfter :: ThreadManager -> IO a -> (Maybe SomeException -> IO ()) -> IO a
- data KilledByThreadManager = KilledByThreadManager (Maybe SomeException)
- forkManaged :: ThreadManager -> String -> IO () -> IO ()
- forkManagedFinally :: ThreadManager -> String -> IO () -> IO () -> IO ()
- forkManagedUnmask :: ThreadManager -> String -> ((forall x. IO x -> IO x) -> IO ()) -> IO ()
- forkManagedTimeout :: ThreadManager -> String -> (Handle -> IO ()) -> IO ()
- forkManagedTimeoutFinally :: ThreadManager -> String -> (Handle -> IO ()) -> IO () -> IO ()
- waitUntilAllGone :: ThreadManager -> IO ()
- data Manager
- withHandle :: ThreadManager -> TimeoutAction -> (Handle -> IO a) -> IO (Maybe a)
- data Handle
- tickle :: Handle -> IO ()
- pause :: Handle -> IO ()
- resume :: Handle -> IO ()
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.
data KilledByThreadManager Source #
An exception used internally to kill a managed thread.
Instances
Exception KilledByThreadManager Source # | |
Show KilledByThreadManager Source # | |
Defined in System.ThreadManager showsPrec :: Int -> KilledByThreadManager -> ShowS # show :: KilledByThreadManager -> String # showList :: [KilledByThreadManager] -> ShowS # |
Fork
:: 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
withHandle :: ThreadManager -> TimeoutAction -> (Handle -> IO a) -> IO (Maybe a) Source #