| Copyright | (c) 2016 Michael Walker |
|---|---|
| License | MIT |
| Maintainer | Michael Walker <mike@barrucadu.co.uk> |
| Stability | experimental |
| Portability | 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.
- 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)
- stepThread :: forall n r s. MonadRef r n => (forall x. s x -> IdSource -> n (Result x, IdSource, TTrace)) -> MemType -> Action n r s -> IdSource -> ThreadId -> Threads n r s -> WriteBuffer r -> Int -> n (Either Failure (Threads n r s, IdSource, ThreadAction, WriteBuffer r, Int))
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
Arguments
| :: MonadRef r n | |
| => (forall x. s x -> IdSource -> n (Result x, IdSource, TTrace)) | Run a |
| -> 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 |
|
| -> 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.