manpagez: man pages & more
info bigloo
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.2.2.3 Signal

Bigloo function: broadcast! signal [val]

Broadcasts signal to all threads started in scheduler immediately, that is during the reaction. This function can only be called from within a running thread. If the optional argument val is omitted, the signal is broadcast with an unspecified value.

(thread-start! (instantiate::fthread
                  (body (lambda ()
                           (thread-await! 'foo)
                           (print (scheduler-instant (current-scheduler)))))))
(thread-start! (instantiate::fthread
                  (body (lambda ()
                           (broadcast! 'foo)))))
(scheduler-start!)
  -| 1
Bigloo function: scheduler-broadcast! scheduler signal [val]

At the next react broadcasts signal to all threads started in scheduler. This is used to impact running threads from outside any threads. If the optional argument val is omitted, the signal is broadcast with an unspecified value.

Bigloo function: make-asynchronous-signal proc

This function invokes in the background, the procedure proc. This function takes one parameter which is the signal that is broadcast when the invocation returns. When the host operating system supports parallel executions, the invocation of proc is executed in parallel with the waiting thread.

Asynchronous signals can be used to implement non blocking system operations, such as input/output. Here is an example that illustrates how to implement concurrent programs that behaves similarly with Fair Threads and Posix Threads.

(define-expander read
   (lambda (x e)
      (cond-expand
	 (fthread
	  (thread-await!
	   (make-aynchronous-signal
	    (lambda (s)
	       (read ,@(map (lambda (x) (e x e)) (cdr x)))))))
	 (else
	  `(read ,@(map (lambda (x) (e x e)) (cdr x)))))))

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on October 23, 2011 using texi2html 5.0.