manpagez: man pages & more
info bigloo
Home | html | info | man
[ < ] [ > ]   [ << ] [ 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: scheduler? obj

Returns #t if obj is a scheduler. Otherwise returns #f.

Bigloo function: current-scheduler

Returns the current scheduler. The current scheduler is the scheduler used in the last call to scheduler-react! or scheduler-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! and thread-sleep!) or because it is waiting a signal (thread-await!). A thread can be selected several times during the same reaction. The function scheduler-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 (see current-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
Bigloo function: scheduler-terminate! [scheduler]

Terminates all the threads in scheduler.

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] [ ? ]
© manpagez.com 2000-2026
Individual documents may contain additional copyright information.