dejafu-2.4.0.5: A library for unit-testing concurrent programs.
Copyright(c) 2016--2018 Michael Walker
LicenseMIT
MaintainerMichael Walker <mike@barrucadu.co.uk>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.DejaFu.Schedule

Description

Scheduling for concurrent computations.

Synopsis

Scheduling

newtype Scheduler state Source #

A Scheduler drives the execution of a concurrent program. The parameters it takes are:

  1. The last thread executed (if this is the first invocation, this is Nothing).
  2. The unblocked threads.
  3. The concurrency state.
  4. 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

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