git.fiddlerwoaroof.com
Browse code

prealpha checkpoint

2010-01-21 Robert Rorschach <rfr@franz.com>

* imap.cl: threadsafe resource management

Robert Rorschach authored on 21/01/2010 20:59:06
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+2010-01-21  Robert Rorschach  <rfr@franz.com>
2
+
3
+	* imap.cl: threadsafe resource management
4
+
1 5
 2009-09-30  Kevin Layer  <layer@gemini.franz.com>
2 6
 
3 7
 	* mime-api.cl: rfe9010: decode-header-text: remove "soft"
... ...
@@ -2101,20 +2101,25 @@
2101 2101
 ;;-- reusable line buffers
2102 2102
 
2103 2103
 (defvar *line-buffers* nil)
2104
+(defvar *line-buffers-lock* (make-basic-lock :name "line-buffers"))
2104 2105
 
2105 2106
 (defun get-line-buffer (size)
2106 2107
   ;; get a buffer of at least size bytes
2107 2108
   (setq size (min size (1- array-total-size-limit)))
2108
-  (mp::without-scheduling
2109
-    (dolist (buff *line-buffers* (make-string size))
2110
-	(if* (>= (length buff) size)
2111
-	   then ; use this one
2112
-		(setq *line-buffers* (delete buff *line-buffers*))
2113
-		(return buff)))))
2109
+  (let ((found 
2110
+	 (with-locked-structure (*line-buffers-lock*
2111
+				 :non-smp :without-scheduling)
2112
+	   (dolist (buff *line-buffers*)
2113
+	     (if* (>= (length buff) size)
2114
+		then ;; use this one
2115
+		     (setq *line-buffers* (delete buff *line-buffers*))
2116
+		     (return buff))))))
2117
+    (or found  (make-string size))))
2114 2118
 
2115 2119
 
2116 2120
 (defun free-line-buffer (buff)
2117
-  (mp:without-scheduling
2121
+  (with-locked-structure (*line-buffers-lock*
2122
+			  :non-smp :without-scheduling)
2118 2123
     (push buff *line-buffers*)))
2119 2124
 
2120 2125
 (defun init-line-buffer (new old)