[Bordeaux-threads-devel] condition-variable in clozure cl.

박성민 byulparan at gmail.com
Wed Jul 11 00:07:17 UTC 2012


clozure cl haven't implements condition-variable. so..

(defun bt:make-condition-variable ()
  (ccl:make-semaphore))


but, condition-variable and semaphore are different. right?
It can cause problems, I think.
Perhaps, It's make meaningless loop.

I just wonder why something like this that you have not implemented in
bordeaux-threads


(in-package #:bordeaux-threads)

(defclass condition-variable ()
  ((sem-count :initform 0 :accessor sem-count)
   (semaphore :initform (ccl:make-semaphore) :reader semaphore)))


(defun make-condition-variable ()
  (make-instance 'condition-variable))


(defun condition-wait (condition-variable lock)
  (unwind-protect (progn (incf (sem-count condition-variable))
 (release-lock lock)
 (ccl:wait-on-semaphore (semaphore condition-variable)))
    (acquire-lock lock)))


(defun condition-notify (condition-variable)
  (when (> (sem-count condition-variable) 0)
    (decf (sem-count condition-variable))
    (ccl:signal-semaphore (semaphore condition-variable))))



I don't know about it....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/bordeaux-threads-devel/attachments/20120711/fc74faec/attachment.html>


More information about the bordeaux-threads-devel mailing list