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

17.3.4 Condition Variables

Posix thread condition variables follows the common thread API (see Thread Common Functions).

(module example
  (library pthread)
  (main main))

(define (main argv)
   (let ((res #f)
	 (lock (make-mutex))
	 (cv (make-condition-variable)))
      (thread-join!
       (thread-start-joinable!
	(instantiate::pthread
	   (body (lambda ()
		    (mutex-lock! lock)
		    (thread-start!
		     (instantiate::pthread
			(body (lambda ()
				 (mutex-lock! lock)
				 (condition-variable-signal! cv)
				 (mutex-unlock! lock)))))
		    (condition-variable-wait! cv lock)
		    (set! res 23) 
		    (mutex-unlock! lock))))))
      res))

This document was generated on March 31, 2014 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.