threads-0.1.0.1: Fork threads and wait for their result

MaintainerBas van Dijk <v.dijk.bas@gmail.com> , Roel van Dijk <vandijk.roel@gmail.com>

Control.Concurrent.Thread.Group

Contents

Description

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 and Control.Concurrent.Thread. Avoid ambiguities by importing one or both qualified. We suggest importing this module like:

 import Control.Concurrent.Thread.Group ( ThreadGroup )
 import qualified Control.Concurrent.Thread.Group as ThreadGroup ( ... )

Synopsis

Creating

new :: IO ThreadGroupSource

Create a new empty group.

Forking threads

forkIO :: ThreadGroup -> IO α -> IO (ThreadId α)Source

Same as Control.Concurrent.Thread.forkIO but additionaly adds the thread to the group.

forkOS :: ThreadGroup -> IO α -> IO (ThreadId α)Source

Same as Control.Concurrent.Thread.forkOS but additionaly adds the thread to the group.

Waiting & Status

wait :: ThreadGroup -> IO ()Source

Block until all threads, that were added to the group have terminated.

isAnyRunning :: ThreadGroup -> IO BoolSource

Returns True if any thread in the group is running and returns False otherwise.

Notice that this observation is only a snapshot of a group's state. By the time a program reacts on its result it may already be out of date.