lifted-base-0.2.1.1: lifted IO operations from the base library

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

Control.Concurrent.Lifted

Contents

Description

This is a wrapped version of Control.Concurrent with types generalized from IO to all monads in either MonadBase or MonadBaseControl.

Synopsis

Concurrent Haskell

data ThreadId

Instances

Eq ThreadId 
Ord ThreadId 
Show ThreadId 
Typeable ThreadId 

Basic concurrency operations

myThreadId :: MonadBase IO m => m ThreadId

Generalized version of myThreadId.

fork :: MonadBaseControl IO m => m () -> m ThreadId

Generalized version of forkIO.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

forkWithUnmask :: MonadBaseControl IO m => ((forall a. m a -> m a) -> m ()) -> m ThreadId

Generalized version of forkIOWithUnmask.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

forkFinally :: MonadBaseControl IO m => m a -> (Either SomeException a -> m ()) -> m ThreadId

Generalized version of forkFinally.

Note that in forkFinally action and_then, while the forked action and the and_then function have access to the captured state, all their side-effects in m are discarded. They're run only for their side-effects in IO.

killThread :: MonadBase IO m => ThreadId -> m ()

Generalized version of killThread.

throwTo :: (MonadBase IO m, Exception e) => ThreadId -> e -> m ()

Generalized version of throwTo.

Threads with affinity

forkOn :: MonadBaseControl IO m => Int -> m () -> m ThreadId

Generalized version of forkOn.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

forkOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall a. m a -> m a) -> m ()) -> m ThreadId

Generalized version of forkOnWithUnmask.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

getNumCapabilities :: MonadBase IO m => m Int

Generalized version of getNumCapabilities.

setNumCapabilities :: MonadBase IO m => Int -> m ()

Generalized version of setNumCapabilities.

threadCapability :: MonadBase IO m => ThreadId -> m (Int, Bool)

Generalized version of threadCapability.

Scheduling

yield :: MonadBase IO m => m ()

Generalized version of yield.

Blocking

Waiting

threadDelay :: MonadBase IO m => Int -> m ()

Generalized version of threadDelay.

threadWaitRead :: MonadBase IO m => Fd -> m ()

Generalized version of threadWaitRead.

threadWaitWrite :: MonadBase IO m => Fd -> m ()

Generalized version of threadWaitWrite.

Communication abstractions

Bound Threads

forkOS :: MonadBaseControl IO m => m () -> m ThreadId

Generalized version of forkOS.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

isCurrentThreadBound :: MonadBase IO m => m Bool

Generalized version of isCurrentThreadBound.

runInBoundThread :: MonadBaseControl IO m => m a -> m a

Generalized version of runInBoundThread.

runInUnboundThread :: MonadBaseControl IO m => m a -> m a

Generalized version of runInUnboundThread.

Weak references to ThreadIds

mkWeakThreadId :: MonadBase IO m => ThreadId -> m (Weak ThreadId)

Generalized versio of mkWeakThreadId.