regions-0.8: Provides the region monad for safely opening and working with scarce resources.

MaintainerBas van Dijk <v.dijk.bas@gmail.com>

Control.Monad.Trans.Region.Concurrent

Description

Concurrently executing regions.

This module exports functions with equivalent names from Control.Concurrent and GHC.Conc. May I suggest you import this module qualified as in:

import qualified Control.Monad.Trans.Region.Concurrent as Region

Synopsis

Documentation

forkIO :: MonadIO pr => RegionT s IO () -> RegionT s pr ThreadIdSource

Return a region which executes the given region in a new thread.

Note that the forked region has the same type variable s as the resulting region. This means that all values which can be referenced in the resulting region can also be referenced in the forked region.

For example the following is allowed:

runRegionT $ do
  regionalHndl <- open resource
  threadId <- Region.forkIO $ doSomethingWith regionalHndl
  doSomethingElseWith regionalHndl

Note that the regionalHndl and all other resources opened in the current thread are closed only when the current thread or the forked thread terminates whichever comes last.

forkOS :: MonadIO pr => RegionT s IO () -> RegionT s pr ThreadIdSource

Like forkIO but internally uses Control.Concurrent.forkOS.

forkOnIO :: MonadIO pr => Int -> RegionT s IO () -> RegionT s pr ThreadIdSource

Like forkIO but internally uses GHC.Conc.forkOnIO.