r9009: add sequence fns
[clsql.git] / base / utils.lisp
index 1584104d72ceb16d8836473cc9c2dc3f245b9ce7..ae1a4b06b14dd119288bc99589bb019225478fe6 100644 (file)
                    (char unescaped i)))))
     escaped))
 
+(defmacro without-interrupts (&body body)
+  #+lispworks `(mp:without-preemption ,@body)
+  #+allegro `(mp:without-scheduling ,@body)
+  #+cmu `(pcl::without-interrupts ,@body)
+  #+sbcl `(sb-sys::without-interrupts ,@body)
+  #+openmcl `(ccl:without-interrupts ,@body))
+
+(defun make-process-lock (name) 
+  #+allegro (mp:make-process-lock :name name)
+  #+cmu (mp:make-lock name)
+  #+lispworks (mp:make-lock :name name)
+  #+openmcl (ccl:make-lock :name name)
+  #+sb-thread (sb-thread:make-mutex :name name)
+  #+scl (thread:make-lock name)
+  #-(or allegro cmu lispworks openmcl sb-thread scl) (declare (ignore name))
+  #-(or allegro cmu lispworks openmcl sb-thread scl) nil)
+
+(defmacro with-process-lock ((lock desc) &body body)
+  #+(or cmu allegro lispworks openmcl sb-thread)
+  (declare (ignore desc))
+  #+(or allegro cmu lispworks openmcl sb-thread)
+  (let ((l (gensym)))
+    `(let ((,l ,lock))
+      #+allegro (mp:with-process-lock (,l) ,@body)
+      #+cmu (mp:with-lock-held (,l) ,@body)
+      #+openmcl (ccl:with-lock-grabbed (,l) ,@body)
+      #+lispworks (mp:with-lock (,l) ,@body)
+      #+sb-thread (sb-thread:with-recursive-lock (,l) ,@body)
+      ))
+  #+scl `(thread:with-lock-held (,lock ,desc) ,@body)
+  #-(or cmu allegro lispworks openmcl sb-thread scl) (declare 
+                                                     (ignore lock desc))
+  #-(or cmu allegro lispworks openmcl sb-thread scl) `(progn ,@body))
 
 (defun sql-escape-quotes (s)
   "Escape quotes for SQL string writing"