Update of /project/elephant/cvsroot/elephant/src/utils In directory clnet:/tmp/cvs-serv12026/src/utils
Added Files: locks.lisp package.lisp Log Message: Fixed bug from last checkin; implemented abstraction for fast-locks for systems that have such a thing (such as without-interrupts in non-parallel lisps)
--- /project/elephant/cvsroot/elephant/src/utils/locks.lisp 2007/02/03 00:57:35 NONE +++ /project/elephant/cvsroot/elephant/src/utils/locks.lisp 2007/02/03 00:57:35 1.1 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;; ;;; cross-platform.lisp -- convert Lisp data to/from byte arrays ;;; ;;; Initial version 8/26/2004 by Ben Lee ;;; blee@common-lisp.net ;;; ;;; part of ;;; ;;; Elephant: an object-oriented database for Common Lisp ;;; ;;; Elephant users are granted the rights to distribute and use this software ;;; as governed by the terms of the Lisp Lesser GNU Public License ;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;
(in-package :elephant-utils)
;; This is a quick portability hack to avoid external dependencies, if we get ;; too many of these do we need to import a standard library? do we need to import ;; 'port' or some other thread layer to the elephant dependency list?
(defun ele-make-lock () #+allegro (mp::make-process-lock) #+cmu (mp:make-lock) #+sbcl (sb-thread:make-mutex) #+mcl (ccl:make-lock) #+lispworks (mp:make-lock) #-(or allegro sbcl cmu lispworks mcl) nil )
(defmacro ele-with-lock ((lock &rest ignored) &body body) (declare (ignore ignored) (ignorable lock)) #+allegro `(mp:with-process-lock (,lock) ,@body) #+cmu `(mp:with-lock-held (,lock) ,@body) #+sbcl `(sb-thread:with-mutex (,lock) ,@body) #+lispworks `(mp:with-lock (,lock) ,@body) #+mcl `(ccl:with-lock-grabbed (,lock) ,@body) #-(or allegro sbcl cmu lispworks mcl) `(progn ,@body) )
;; ;; For tight loops we need a fast lock, for lisps that support this ;; with-interrupts or something similar this can help performance ;;
(defun ele-make-fast-lock () #+allegro nil #-allegro (ele-make-lock))
(defmacro ele-with-fast-lock ((lock &rest ignored) &body body) (declare (ignorable lock ignored)) #+allegro `(excl:without-interrupts ,@body) #-allegro `(ele-with-lock (,lock ,@ignored) ,@body))
--- /project/elephant/cvsroot/elephant/src/utils/package.lisp 2007/02/03 00:57:35 NONE +++ /project/elephant/cvsroot/elephant/src/utils/package.lisp 2007/02/03 00:57:35 1.1 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;; ;;; package.lisp -- package definition ;;; ;;; Initial version 2/3/2007 by Ian Eslick ;;; ieslick@common-lisp.net ;;; ;;; part of ;;; ;;; Elephant: an object-oriented database for Common Lisp ;;; ;;; Copyright (c) 2004 by Andrew Blumberg and Ben Lee ;;; ablumberg@common-lisp.net blee@common-lisp.net ;;; ;;; Elephant users are granted the rights to distribute and use this software ;;; as governed by the terms of the Lisp Lesser GNU Public License ;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;
(in-package :cl-user)
(defpackage elephant-utils (:use common-lisp) (:export #:ele-make-lock #:ele-with-lock #:ele-make-fast-lock #:ele-with-fast-lock))