From 36508100346b3159ee3f1fade42a534df8fe15ec Mon Sep 17 00:00:00 2001
From: Matthias Benkard <code@mail.matthias.benkard.de>
Date: Sat, 16 Feb 2008 16:19:39 +0100
Subject: Add a few locking utility stubs.

darcs-hash:89727f37535b1a2b8360f2e9055952034fd6db9f
---
 Lisp/internal-utilities.lisp | 27 +++++++++++++++++++++++++--
 Lisp/parameters.lisp         |  2 ++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/Lisp/internal-utilities.lisp b/Lisp/internal-utilities.lisp
index 1c54068..87746b9 100644
--- a/Lisp/internal-utilities.lisp
+++ b/Lisp/internal-utilities.lisp
@@ -19,8 +19,31 @@
 
 
 (defmacro atomically (&body body)
-  ;; FIXME: Use a reentrant global lock here.
-  `(progn ,@body))
+  ;; FIXME
+  `(progn ,@body)
+  #+(or)
+  `(prog2
+     (objcl-acquire-global-lock)
+     ,@body
+     (objcl-release-global-lock)))
+
+
+(defmacro with-exclusive-access ((&rest objects) &body body)
+  (etypecase objects
+    (null `(progn ,@body))
+    (cons `(with-lock ,(first objects)
+             (with-exclusive-access (,(rest objects))
+               ,@body)))))
+
+
+(defmacro with-lock (object &body body)
+  ;; FIXME: Implement LOCK-FOR-OBJECT.
+  (let ((lock (gensym "LOCK")))
+    `(let ((,lock (lock-for-object ,object)))
+       (prog2
+         (%objcl-acquire-lock ,lock)
+         (progn ,@body)
+         (%objcl-release-lock ,lock)))))
 
 
 (defun featurep (symbol)
diff --git a/Lisp/parameters.lisp b/Lisp/parameters.lisp
index 875adb8..a26908b 100644
--- a/Lisp/parameters.lisp
+++ b/Lisp/parameters.lisp
@@ -20,6 +20,8 @@
 
 (defvar *runtime-initialisation-level* 0)
 
+(defvar *object-locks* (make-hash-table :test 'eql))
+
 (defvar *boolean-return-exceptions* (make-hash-table :test #'equal))
 
 (defvar *skip-retaining* nil)
-- 
cgit v1.2.3