[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
17.2.2.2 Scheduler
- Bigloo function: make-scheduler [strict-order?] [envs]
Creates a new scheduler. The optional boolean argument
strict-order?
is used to ask the scheduler to always schedule the threads in the same order, it defaults to#f
. The optional arguments envs are fair thread environments which will be defined in forthcoming Bigloo releases.
- Bigloo function: scheduler-strict-order?
- Bigloo function: scheduler-strict-order?-set! bool
Gets or sets the strict scheduling policy of the scheduler. If set, the threads will always be scheduled in the same order, until their termination. By default, it is set to false, which improve performances when there is a lot of thread to schedule.
- Bigloo function: current-scheduler
Returns the current scheduler. The current scheduler is the scheduler which currently schedules the current thread. This value is not mutable, as it is set during the call to
thread-start!
.
- Bigloo function: default-scheduler [scheduler]
Sets or gets the default scheduler. The default scheduler is the scheduler that will be used in the calls to
scheduler-react!
,scheduler-start!
orthread-start!
if not specified. It always exists a default scheduler. That is, it is optional for an application to create a scheduler.
- Bigloo function: scheduler-react! [scheduler]
Executes all the threads started (see
thread-start!
, Section Thread) in the scheduler until all the threads are blocked. A thread is blocked if the has explicitly yield the processor (thread-yield!
andthread-sleep!
) or because it is waiting a signal (thread-await!
). A thread can be selected several times during the same reaction. The functionscheduler-react!
returns a symbol denoting the state of the scheduler. The possible states are:-
ready
The Scheduler is ready to execute some threads. -
done
All the threads started in the scheduler have terminated. -
await
All the threads started in the scheduler are waiting for a signal.
An invocation of
scheduler-react!
is called a reaction.-
- Bigloo function: scheduler-start! [arg [scheduler]]
Executes
scheduler-react!
as long as the scheduler is not done. If the optional argument scheduler is not provided,scheduler-start!
uses the current scheduler (seecurrent-scheduler
). The optional arg can either be:- An integer standing for the number of times
scheduler-react!
must be called. - A procedure f of one argument. The procedure f
is invoked after each reaction. It is passed a value i which is
the iteration number of the scheduler. The reactions of the scheduler
continue while f returns
#f
.
(let* ((s (make-scheduler)) (t (instantiate::fthread (body (lambda () (let loop ((n 0)) (display n) (thread-yield!) (loop (+ 1 n)))))))) (scheduler-start! 10 s)) -| 0123456789 (let* ((s (make-scheduler)) (t (instantiate::fthread (body (lambda () (let loop ((n 0)) (display n) (thread-yield!) (loop (+ 1 n)))))))) (scheduler-start! (lambda (i) (read-char)) s)) -| 0123456789
- An integer standing for the number of times
- Bigloo function: scheduler-instant [scheduler]
Returns the current reaction number of scheduler. The reaction number is the number of times
scheduler-react!
has been invoked passing scheduler as argument.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.