Copyright | (c) 2016 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | experimental |
Portability | RankNTypes, ScopedTypeVariables |
Safe Haskell | None |
Language | Haskell2010 |
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, NonEmpty Lookahead)], ThreadAction)
- runConcurrency :: MonadRef r n => Scheduler g -> MemType -> g -> Int -> M n r a -> n (Either Failure a, g, SeqTrace)
- data Context n r g = Context {
- cSchedState :: g
- cIdSource :: IdSource
- cThreads :: Threads n r
- cWriteBuf :: WriteBuffer r
- cCaps :: Int
- runThreads :: MonadRef r n => Scheduler g -> MemType -> r (Maybe (Either Failure a)) -> Context n r g -> n (Context n r g, SeqTrace)
- stepThread :: forall n r g. MonadRef r n => Scheduler g -> MemType -> ThreadId -> Action n r -> Context n r g -> n (Either Failure (Context n r g, Either (ThreadAction, SeqTrace) ThreadAction))
Execution
type SeqTrace = Seq (Decision, [(ThreadId, NonEmpty Lookahead)], ThreadAction) Source #
Trace
but as a sequence.
runConcurrency :: MonadRef r n => Scheduler g -> MemType -> g -> Int -> M n r a -> n (Either Failure a, g, SeqTrace) 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.
Context | |
|
runThreads :: MonadRef r n => Scheduler g -> MemType -> r (Maybe (Either Failure a)) -> Context n r g -> n (Context n r g, SeqTrace) Source #
Run a collection of threads, until there are no threads left.
Single-step execution
:: 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, Either (ThreadAction, SeqTrace) ThreadAction)) |
Run a single thread one step, by dispatching on the type of
Action
.