| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
17.2.2.2 Scheduler
- Bigloo function: make-scheduler [envs]
Creates a new scheduler. The optional arguments envs are fair thread environments which will be defined in forthcoming Bigloo releases.
- Bigloo function: current-scheduler
Returns the current scheduler. The current scheduler is the scheduler used in the last call to
scheduler-react!orscheduler-start!. It always exists a current scheduler. That is, it is optional for an application to create a scheduler.
- Bigloo function: scheduler-react! [scheduler]
Executes all the treads 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:-
readyThe Scheduler is ready to execute some threads. -
doneAll the threads started in the scheduler have terminated. -
awaitAll 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
are stopped when f returns
#f.
(let* ((s (make-scheduler)) (t (make-thread (lambda () (let loop ((n 0)) (display n) (thread-yield!) (loop (+ 1 n))))))) (scheduler-start! 10 s)) -| 0123456789 (let* ((s (make-scheduler)) (t (make-thread (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] | [ ? ] |
