1.0.10.14: remove locking and gc inhibition from hash-tables, power of 2 sizes
[sbcl.git] / src / code / gc.lisp
index df569ed..bc6f6cd 100644 (file)
@@ -180,6 +180,22 @@ run in any thread.")
 (defvar *already-in-gc*
   (sb!thread:make-mutex :name "GC lock") "ID of thread running SUB-GC")
 
+;;; A unique GC id. This is supplied for code that needs to detect
+;;; whether a GC has happened since some earlier point in time. For
+;;; example:
+;;;
+;;;   (let ((epoch *gc-epoch*))
+;;;      ...
+;;;      (unless (eql epoch *gc-epoch)
+;;;        ....))
+;;;
+;;; This isn't just a fixnum counter since then we'd have theoretical
+;;; problems when exactly 2^29 GCs happen between epoch
+;;; comparisons. Unlikely, but the cost of using a cons instead is too
+;;; small to measure. -- JES, 2007-09-30
+(declaim (type cons *gc-epoch*))
+(defvar *gc-epoch* (cons nil nil))
+
 (defun sub-gc (&key (gen 0))
   (unless (eq sb!thread:*current-thread*
               (sb!thread::mutex-value *already-in-gc*))
@@ -202,6 +218,7 @@ run in any thread.")
                  (gc-stop-the-world)
                  (let ((start-time (get-internal-run-time)))
                    (collect-garbage gen)
+                   (setf *gc-epoch* (cons nil nil))
                    (incf *gc-run-time*
                          (- (get-internal-run-time) start-time)))
                  (setf *gc-pending* nil