Copyright | (c) 2016--2018 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Scheduling for concurrent computations.
Synopsis
- newtype Scheduler state = Scheduler {
- scheduleThread :: Maybe (ThreadId, ThreadAction) -> NonEmpty (ThreadId, Lookahead) -> ConcurrencyState -> state -> (Maybe ThreadId, state)
- randomSched :: RandomGen g => Scheduler g
- roundRobinSched :: Scheduler ()
- randomSchedNP :: RandomGen g => Scheduler g
- roundRobinSchedNP :: Scheduler ()
- makeNonPreemptive :: Scheduler s -> Scheduler s
Scheduling
newtype Scheduler state Source #
A Scheduler
drives the execution of a concurrent program. The
parameters it takes are:
- The last thread executed (if this is the first invocation, this
is
Nothing
). - The unblocked threads.
- The concurrency state.
- The scheduler state.
It returns a thread to execute, or Nothing
if execution should
abort here, and also a new state.
Since: 2.0.0.0
Scheduler | |
|
Preemptive
randomSched :: RandomGen g => Scheduler g Source #
A simple random scheduler which, at every step, picks a random thread to run.
Since: 0.8.0.0
roundRobinSched :: Scheduler () Source #
A round-robin scheduler which, at every step, schedules the
thread with the next ThreadId
.
Since: 0.8.0.0
Non-preemptive
randomSchedNP :: RandomGen g => Scheduler g Source #
A random scheduler which doesn't preempt the running thread. That is, if the previously scheduled thread is not blocked, it is picked again, otherwise schedule randomly.
Since: 0.8.0.0
roundRobinSchedNP :: Scheduler () Source #
A round-robin scheduler which doesn't preempt the running
thread. That is, if the previously scheduled thread is not blocked,
it is picked again, otherwise schedule the thread with the next
ThreadId
.
Since: 0.8.0.0
Utilities
makeNonPreemptive :: Scheduler s -> Scheduler s Source #
Turn a potentially preemptive scheduler into a non-preemptive one.
Since: 0.8.0.0