Manager to manage the thread and the timer.
Moduletime-manager-0.3.2Haskell2010
System.ThreadManager
A thread manager including a time manager. The manager has responsibility to kill managed threads.
Because this is based on the accompanying System.TimeManager module, the same caveats apply:
Only works for GHC.
Only works with a threaded runtime.
Users of older versions should check the current semantics.
Using 32-bit systems means the max timeout is
maxBound :: Int(2147483647) microseconds, which is less than 36 minutes.Using the same
Handlein different threads might cause issues in some edge cases. (i.e. using cancel/pause in one thread, and resume in another)
- 4 types
- 14 values
- Packagetime-manager-0.3.2
- Exports18
- LanguageHaskell2010
- LicenceMIT
- SourceThreadManager.hs
Create a thread manager.
To create a ThreadManager, you will first have to create a Manager from the System.TimeManager module.
You can use either initialize or withManager.
Stopping the manager.
stopAfter threadManager action cleanup
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.
An exception used internally to kill a managed thread.
Constructors
Instances2Show, Exception
Show KilledByThreadManagerDefined in time-manager-0.3.2 · System.ThreadManagerException KilledByThreadManagerDefined in time-manager-0.3.2 · System.ThreadManager
Fork
5 declarationsFork 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-> StringThread name
-> IO ()Action
-> IO ()Cleanup function
-> IO ()
Fork a managed thread with a cleanup function.
forkManagedUnmask Like forkManaged, but run action with exceptions masked
forkManagedTimeout :: ThreadManager-> StringThread name
-> (Handle -> IO ())Action with timeout handle
-> IO ()
Fork a managed thread with a handle created by a timeout manager.
Fork a managed thread with a handle created by a timeout manager and with a cleanup function.
Synchronization
2 declarationsWait until all managed threads are finished.
STM action that checks if all managed threads are finished.
Re-exports
6 declarationsA timeout manager
Registering a TimeoutAction and unregister its Handle when the body action is finished.
A handle used by a timeout manager.
Extending the timeout.
Careful: this does NOT reactivate an already paused Handle!