Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> , Roel van Dijk <vandijk.roel@gmail.com> |
---|
This module extends Control.Concurrent.Thread
with the ability to wait for
a group of threads to terminate.
This module exports equivalently named functions from Control.Concurrent
,
(GHC.Conc
), and Control.Concurrent.Thread
. Avoid ambiguities by importing
this module qualified. May we suggest:
import Control.Concurrent.Thread.Group ( ThreadGroup ) import qualified Control.Concurrent.Thread.Group as ThreadGroup ( ... )
- data ThreadGroup
- new :: IO ThreadGroup
- forkIO :: ThreadGroup -> IO α -> IO (ThreadId, Result α)
- forkOS :: ThreadGroup -> IO α -> IO (ThreadId, Result α)
- forkOnIO :: Int -> ThreadGroup -> IO α -> IO (ThreadId, Result α)
- wait :: ThreadGroup -> IO ()
- isAnyRunning :: ThreadGroup -> IO Bool
Groups of threads
data ThreadGroup Source
A ThreadGroup
can be understood as a counter which counts the number of
threads that were added to the group minus the ones that have terminated.
More formally a ThreadGroup
has the following semantics:
Create an empty group of threads.
Forking threads
forkIO :: ThreadGroup -> IO α -> IO (ThreadId, Result α)Source
Same as Control.Concurrent.Thread.
but additionaly adds
the thread to the group.
forkIO
forkOS :: ThreadGroup -> IO α -> IO (ThreadId, Result α)Source
Same as Control.Concurrent.Thread.
but additionaly adds
the thread to the group.
forkOS
forkOnIO :: Int -> ThreadGroup -> IO α -> IO (ThreadId, Result α)Source
Same as Control.Concurrent.Thread.
but
additionaly adds the thread to the group. (GHC only)
forkOnIO
Waiting & Status
wait :: ThreadGroup -> IO ()Source
Block until all threads, that were added to the group have terminated.
isAnyRunning :: ThreadGroup -> IO BoolSource