thread-hierarchy-0.1.0.0: Simple Haskel thread management in hierarchical manner

Copyright(c) Naoto Shimazaki 2017
LicenseMIT (see the file LICENSE)
Maintainerhttps://github.com/nshimaza
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Control.Concurrent.HierarchyInternal

Description

Internal implementations of Control.Concurrent.Hierarchy

Synopsis

Documentation

newtype FinishMarker Source #

FinishMarker is created as empty MVar when a thread is created. It is automatically filled by () when the thread exits.

Constructors

FinishMarker (MVar ()) 

newtype ThreadMap Source #

Mutable map containing thread ID and finish marker.

newThreadMap :: MonadBase IO m => m ThreadMap Source #

Create a new empty ThreadMap.

newChild Source #

Arguments

:: 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.

killThreadHierarchy Source #

Arguments

:: MonadBase IO m 
=> ThreadMap

ThreadMap containing threads to be killed

-> m () 

Kill all thread registered in given ThreadMap.

newFinishMarker :: MonadBase IO m => m FinishMarker Source #

Create new empty finish marker. Internal use only.

markFinish :: MonadBase IO m => FinishMarker -> m () Source #

Filling MVar of finish marker to mark thread finished. Only used by cleanup routine internally.

waitFinish :: MonadBase IO m => FinishMarker -> m () Source #

Wait for finish marker marked. Only used by killThreadHierarchy routine internally.

cleanup :: MonadBase 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.