Copyright | (c) Naoto Shimazaki 2017 |
---|---|
License | MIT (see the file LICENSE) |
Maintainer | https://github.com/nshimaza |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
Internal implementations of Control.Concurrent.Hierarchy
- newtype FinishMarker = FinishMarker (MVar ())
- newtype ThreadMap = ThreadMap (TVar (Map ThreadId FinishMarker))
- newThreadMap :: MonadBase IO m => m ThreadMap
- newChild :: MonadBaseControl IO m => ThreadMap -> (ThreadMap -> m ()) -> m ThreadId
- killThreadHierarchy :: MonadBaseControl IO m => ThreadMap -> m ()
- killThreadHierarchyInternal :: MonadBaseControl IO m => ThreadMap -> m ()
- cleanup :: MonadBaseControl IO m => FinishMarker -> ThreadMap -> ThreadMap -> m ()
Documentation
newtype FinishMarker Source #
FinishMarker is created as empty MVar when a thread is created. It is automatically filled by () when the thread exits.
FinishMarker (MVar ()) |
Mutable map containing thread ID and finish marker.
:: MonadBaseControl IO m | |
=> ThreadMap | ThreadMap where newly created thread will be registered. |
-> (ThreadMap -> m ()) | Action executed within the new thread. |
-> m ThreadId | newChild returns ThreadId of created thread. |
Create a new thread and register it to given ThreadMap
.
:: MonadBaseControl IO m | |
=> ThreadMap | ThreadMap containing threads to be killed |
-> m () |
Kill all thread registered in given ThreadMap
.
This version is exposed as API. This is not called from cleanup routine.
Thus it doesn't ignore asynchronous exceptions.
killThreadHierarchyInternal Source #
:: MonadBaseControl IO m | |
=> ThreadMap | ThreadMap containing threads to be killed |
-> m () |
Kill all thread registered in given ThreadMap
.
This internal version is only called from cleanup routine so
this ignores ThreadKilled asynchronous exception.
cleanup :: MonadBaseControl IO m => FinishMarker -> ThreadMap -> ThreadMap -> m () Source #
Thread clean up routine automatically installed by newChild. It first killThreadHierarchy all its child threads and unregister itself. This function is not an API function but for internal use only.