[isidorus-cvs] r698 - trunk/src/threading

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Mon Aug 1 10:39:46 UTC 2011

Author: lgiessmann
Date: Mon Aug  1 03:39:45 2011
New Revision: 698

trunk: replaced the bordeaux-threads mehtods for using mutexes/locks by the interface of sb-thread


Modified: trunk/src/threading/reader-writer.lisp
--- trunk/src/threading/reader-writer.lisp	Mon Aug  1 01:29:59 2011	(r697)
+++ trunk/src/threading/reader-writer.lisp	Mon Aug  1 03:39:45 2011	(r698)
@@ -8,39 +8,38 @@
 (defpackage :isidorus-threading
-  (:use :cl :bordeaux-threads)
+  (:use :cl :sb-thread)
   (:export :current-readers
 (in-package :isidorus-threading)
-(defvar *readerlist-lock* (make-lock "isidorus-threading: current readers lock"))
-(defvar *writer-lock* (make-lock "isidorus-threading: writer lock"))
+(defvar *readerlist-lock* (make-mutex :name "isidorus-threading: current readers lock"))
+(defvar *writer-lock* (make-mutex :name "isidorus-threading: writer lock"))
 (defvar *current-readers* nil)
 (defun current-readers ()
   "Returns a copy of the list which contains all current reader
    threads, *current-readers*"
-  (let ((result nil))
-    (with-lock-held (*readerlist-lock*)
-      (setf result (copy-list *current-readers*)))
-    result))
+  (with-mutex (*readerlist-lock*)
+    (copy-list *current-readers*)))
 (defun add-thread-to-reader-list ()
   "Adds the current thread to the reader list"
-  (with-lock-held (*writer-lock*)
-    (with-lock-held (*readerlist-lock*)
-      (push (current-thread) *current-readers*))))
+  (with-mutex (*writer-lock*)
+    (with-mutex (*readerlist-lock*)
+      (push *current-thread* *current-readers*))))
 (defun remove-thread-from-reader-list ()
   "Removes the current threads from the reader list"
-  (with-lock-held (*readerlist-lock*)
+  (with-mutex (*readerlist-lock*)
     (setf *current-readers*
-	  (delete (current-thread) *current-readers*))))
+	  (delete *current-thread* *current-readers*))))
 (defmacro with-reader-lock (&body body)
@@ -61,7 +60,7 @@
 (defmacro with-writer-lock (&body body)
   "Executes the passed body when the reader list is empty otherwise
    the do macor loops in 500 ms time interval for a next chance."
-  `(with-lock-held (*writer-lock*)
+  `(with-mutex (*writer-lock*)
       ((remaining-readers (current-readers) (current-readers)))
       ((null remaining-readers))

More information about the Isidorus-cvs mailing list