| Copyright | (c) 2016--2017 Michael Walker |
|---|---|
| License | MIT |
| Maintainer | Michael Walker <mike@barrucadu.co.uk> |
| Stability | experimental |
| Portability | MultiParamTypeClasses, RankNTypes, ScopedTypeVariables |
| Safe Haskell | None |
| Language | Haskell2010 |
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.
- type SeqTrace = Seq (Decision, [(ThreadId, Lookahead)], ThreadAction)
- runConcurrency :: (MonadConc n, MonadRef r n) => Scheduler g -> MemType -> g -> IdSource -> Int -> M n r a -> n (Either Failure a, Context n r g, SeqTrace, Maybe (ThreadId, ThreadAction))
- data Context n r g = Context {
- cSchedState :: g
- cIdSource :: IdSource
- cThreads :: Threads n r
- cWriteBuf :: WriteBuffer r
- cCaps :: Int
- runThreads :: (MonadConc n, MonadRef r n) => Scheduler g -> MemType -> r (Maybe (Either Failure a)) -> Context n r g -> n (Context n r g, SeqTrace, Maybe (ThreadId, ThreadAction))
- data Act
- = Single ThreadAction
- | SubC SeqTrace (Maybe (ThreadId, ThreadAction))
- stepThread :: forall n r g. (MonadConc n, MonadRef r n) => Scheduler g -> MemType -> ThreadId -> Action n r -> Context n r g -> n (Either Failure (Context n r g), Act)
Execution
type SeqTrace = Seq (Decision, [(ThreadId, Lookahead)], ThreadAction) Source #
Trace but as a sequence.
runConcurrency :: (MonadConc n, MonadRef r n) => Scheduler g -> MemType -> g -> IdSource -> Int -> M n r a -> n (Either Failure a, Context n r g, SeqTrace, Maybe (ThreadId, ThreadAction)) Source #
Run a concurrent computation with a given Scheduler and initial
state, returning a failure reason on error. Also returned is the
final state of the scheduler, and an execution trace.
The context a collection of threads are running in.
Constructors
| Context | |
Fields
| |
runThreads :: (MonadConc n, MonadRef r n) => Scheduler g -> MemType -> r (Maybe (Either Failure a)) -> Context n r g -> n (Context n r g, SeqTrace, Maybe (ThreadId, ThreadAction)) Source #
Run a collection of threads, until there are no threads left.
Single-step execution
What a thread did.
Constructors
| Single ThreadAction | Just one action. |
| SubC SeqTrace (Maybe (ThreadId, ThreadAction)) | Subconcurrency, with the given trace and final action. |
Arguments
| :: (MonadConc n, MonadRef r n) | |
| => Scheduler g | The scheduler. |
| -> MemType | The memory model to use. |
| -> ThreadId | ID of the current thread |
| -> Action n r | Action to step |
| -> Context n r g | The execution context. |
| -> n (Either Failure (Context n r g), Act) |
Run a single thread one step, by dispatching on the type of
Action.