dejafu-0.5.0.0: Systematic testing for Haskell concurrency.

Copyright (c) 2016 Michael Walker MIT Michael Walker experimental portable Safe Haskell2010

Test.DejaFu.Schedule

Description

Scheduling for concurrent computations.

Synopsis

# Scheduling

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

1. The trace so far.
2. The last thread executed (if this is the first invocation, this is Nothing).
3. The runnable threads at this point.
4. The state.

It returns a thread to execute, or Nothing if execution should abort here, and also a new state.

data Decision Source #

Scheduling decisions are based on the state of the running program, and so we can capture some of that state in recording what specific decision we made.

Constructors

 Start ThreadId Start a new thread, because the last was blocked (or it's the start of computation). Continue Continue running the last thread for another step. SwitchTo ThreadId Pre-empt the running thread, and switch to another.

Instances

 Source # Methods Source # MethodsshowList :: [Decision] -> ShowS #

Get the resultant thread identifier of a Decision, with a default case for Continue.

Arguments

Get the Decision that would have resulted in this thread identifier, given a prior thread (if any) and list of runnable threads.

data NonEmpty a :: * -> * #

Non-empty (and non-strict) list type.

Since: 4.9.0.0

Constructors

 a :| [a] infixr 5

Instances

## Preemptive

A simple random scheduler which, at every step, picks a random thread to run.

A round-robin scheduler which, at every step, schedules the thread with the next ThreadId.

## Non-preemptive

A random scheduler which doesn't preempt the running thread. That is, if the last thread scheduled is still runnable, run that, otherwise schedule randomly.

A round-robin scheduler which doesn't preempt the running thread.

# Utilities

Turn a potentially preemptive scheduler into a non-preemptive one.