IOSpec-0.1.1: A pure specification of the IO monad.Source codeContentsIndex
Test.IOSpec.Concurrent
Contents
The IOConc monad
Supported functions
Schedulers
Description
A pure specification of basic concurrency operations.
Synopsis
data IOConc a
runIOConc :: IOConc a -> Scheduler -> Maybe a
data ThreadId
data MVar a
newEmptyMVar :: IOConc (MVar a)
takeMVar :: Typeable a => MVar a -> IOConc a
putMVar :: Typeable a => MVar a -> a -> IOConc ()
forkIO :: IOConc a -> IOConc ThreadId
newtype Scheduler = Scheduler (Int -> (ThreadId, Scheduler))
streamSched :: Stream Int -> Scheduler
roundRobin :: Scheduler
The IOConc monad
data IOConc a Source
show/hide Instances
runIOConc :: IOConc a -> Scheduler -> Maybe aSource
The runIOConc function runs a concurrent computation with a given scheduler. If a deadlock occurs, Nothing is returned.
Supported functions
data ThreadId Source
show/hide Instances
data MVar a Source
An MVar is a shared, mutable variable.
show/hide Instances
newEmptyMVar :: IOConc (MVar a)Source
The newEmptyMVar function creates a new MVar that is initially empty.
takeMVar :: Typeable a => MVar a -> IOConc aSource
The takeMVar function removes the value stored in an MVar. If the MVar is empty, the thread is blocked.
putMVar :: Typeable a => MVar a -> a -> IOConc ()Source
The putMVar function fills an MVar with a new value. If the MVar is not empty, the thread is blocked.
forkIO :: IOConc a -> IOConc ThreadIdSource
The forkIO function forks off a new thread.
Schedulers
newtype Scheduler Source
A scheduler consists of a function that, given the number of threads, returns the ThreadId of the next scheduled thread, together with a new scheduler.
Constructors
Scheduler (Int -> (ThreadId, Scheduler))
streamSched :: Stream Int -> SchedulerSource
Given a stream of integers, streamSched builds a scheduler. This is especially useful if you use QuickCheck and generate a random stream; the resulting random scheduler will hopefully cover a large number of interleavings.
roundRobin :: SchedulerSource
A simple round-robin scheduler.
Produced by Haddock version 2.6.0