[elephant-cvs] CVS elephant/src/utils

ieslick ieslick at common-lisp.net
Sat Feb 3 00:57:35 UTC 2007


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 at 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) , at body)
  #+cmu `(mp:with-lock-held (,lock) , at body)
  #+sbcl `(sb-thread:with-mutex (,lock) , at body)
  #+lispworks `(mp:with-lock (,lock) , at body)
  #+mcl `(ccl:with-lock-grabbed (,lock) , at body)
  #-(or allegro sbcl cmu lispworks mcl) `(progn , at 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 , at body)
  #-allegro `(ele-with-lock (,lock , at ignored) , at 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 at common-lisp.net>
;;; 
;;; part of
;;;
;;; Elephant: an object-oriented database for Common Lisp
;;;
;;; Copyright (c) 2004 by Andrew Blumberg and Ben Lee
;;; <ablumberg at common-lisp.net> <blee at 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))



More information about the Elephant-cvs mailing list