Copyright  (c) 2016 Michael Walker 

License  MIT 
Maintainer  Michael Walker <mike@barrucadu.co.uk> 
Stability  experimental 
Portability  portable 
Safe Haskell  Safe 
Language  Haskell2010 
Scheduling for concurrent computations.
 newtype Scheduler state = Scheduler {
 scheduleThread :: Maybe (ThreadId, ThreadAction) > NonEmpty (ThreadId, Lookahead) > state > (Maybe ThreadId, state)
 data Decision
 tidOf :: ThreadId > Decision > ThreadId
 decisionOf :: Foldable f => Maybe ThreadId > f ThreadId > ThreadId > Decision
 data NonEmpty a :: * > * = a : [a]
 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 runnable threads at this point.
 The state.
It returns a thread to execute, or Nothing
if execution should
abort here, and also a new state.
Since: 0.8.0.0
Scheduler  

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.
Since: 0.5.0.0
:: Foldable f  
=> Maybe ThreadId  The prior thread. 
> f ThreadId  The runnable threads. 
> ThreadId  The current thread. 
> Decision 
Get the Decision
that would have resulted in this thread identifier,
given a prior thread (if any) and list of runnable threads.
Since: 0.5.0.0
Nonempty (and nonstrict) list type.
Since: 4.9.0.0
a : [a] infixr 5 
Monad NonEmpty  
Functor NonEmpty  
MonadFix NonEmpty  
Applicative NonEmpty  
Foldable NonEmpty  
Traversable NonEmpty  
Generic1 NonEmpty  
MonadZip NonEmpty  
IsList (NonEmpty a)  
Eq a => Eq (NonEmpty a)  
Data a => Data (NonEmpty a)  
Ord a => Ord (NonEmpty a)  
Read a => Read (NonEmpty a)  
Show a => Show (NonEmpty a)  
Generic (NonEmpty a)  
Semigroup (NonEmpty a)  
NFData a => NFData (NonEmpty a)  Since: 1.4.2.0 
type Rep1 NonEmpty  
type Rep (NonEmpty a)  
type Item (NonEmpty a)  
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 roundrobin scheduler which, at every step, schedules the
thread with the next ThreadId
.
Since: 0.8.0.0
Nonpreemptive
randomSchedNP :: RandomGen g => Scheduler g Source #
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.
Since: 0.8.0.0
roundRobinSchedNP :: Scheduler () Source #
A roundrobin scheduler which doesn't preempt the running thread.
Since: 0.8.0.0
Utilities
makeNonPreemptive :: Scheduler s > Scheduler s Source #
Turn a potentially preemptive scheduler into a nonpreemptive one.
Since: 0.8.0.0