HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulethreads-0.5.1.8Haskell2010

Control.Concurrent.Thread.Group

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 ( ... )
  • 1 type
  • 9 values
  • Packagethreads-0.5.1.8
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGroup.hs
newtypenewtype ThreadGroup
#

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:

  • new initializes the counter to 0.

  • Forking a thread increments the counter.

  • When a forked thread terminates, whether normally or by raising an exception, the counter is decremented.

  • nrOfRunning yields a transaction that returns the counter.

  • wait blocks as long as the counter is greater than 0.

  • waitN blocks as long as the counter is greater or equal to the specified number.

Instances1Eq
  • Eq ThreadGroupDefined in threads-0.5.1.8 · Control.Concurrent.Thread.Group

Yield a transaction that returns the number of running threads in the group.

Note that because this function yields a STM computation, the returned number is guaranteed to be consistent inside the transaction.

valuewait :: ThreadGroup -> IO ()
#

Block until all threads in the group have terminated.

Note that: wait = waitN 1.

valuewaitN :: Int -> ThreadGroup -> IO ()
#

Block until there are fewer than N running threads in the group.

Forking threads

5 declarations