dejafu-0.4.0.0: Systematic testing for Haskell concurrency.

Copyright(c) 2016 Michael Walker
LicenseMIT
MaintainerMichael Walker <mike@barrucadu.co.uk>
Stabilityexperimental
PortabilityRankNTypes, ScopedTypeVariables
Safe HaskellNone
LanguageHaskell2010

Test.DejaFu.Conc.Internal

Contents

Description

Concurrent monads with a fixed scheduler: internal types and functions. This module is NOT considered to form part of the public interface of this library.

Synopsis

Execution

runThreads :: MonadRef r n => (forall x. s x -> IdSource -> n (Result x, IdSource, TTrace)) -> Scheduler ThreadId ThreadAction Lookahead g -> MemType -> g -> Threads n r s -> IdSource -> r (Maybe (Either Failure a)) -> n (g, Trace ThreadId ThreadAction Lookahead) Source #

Run a collection of threads, until there are no threads left.

Note: this returns the trace in reverse order, because it's more efficient to prepend to a list than append. As this function isn't exposed to users of the library, this is just an internal gotcha to watch out for.

Single-step execution

stepThread Source #

Arguments

:: MonadRef r n 
=> (forall x. s x -> IdSource -> n (Result x, IdSource, TTrace))

Run a MonadSTM transaction atomically.

-> MemType

The memory model

-> Action n r s

Action to step

-> IdSource

Source of fresh IDs

-> ThreadId

ID of the current thread

-> Threads n r s

Current state of threads

-> WriteBuffer r

CRef write buffer

-> Int

The number of capabilities

-> n (Either Failure (Threads n r s, IdSource, ThreadAction, WriteBuffer r, Int)) 

Run a single thread one step, by dispatching on the type of Action.