Ignore:
Timestamp:
Jan 4, 2011, 5:41:56 PM (9 years ago)
Author:
gz
Message:

Make *GENSYM-COUNTER* global. This means (GENSYM) will generate
globally unique pnames, though it also means multi-threaded code that
explicitly modifies *GENSYM-COUNTER* may need to do appropriate locking
or binding to achieve whatever effect it is hoping to achieve. See
ticket:799 for discussion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-utils.lisp

    r13647 r14553  
    755755;;;;;;;;; VALUE BINDING Functions
    756756
     757;; Lock used only to make sure calls to GENSYM don't step on each other.  Users who
     758;; modify *gensym-counter* in multi-threaded apps will need to do their own locking.
     759(defparameter *gensym-lock* (make-lock))
     760
    757761(defun gensym (&optional (string-or-integer nil string-or-integer-p))
    758762  "Creates a new uninterned symbol whose name is a prefix string (defaults
     
    769773        (string (setq prefix (ensure-simple-string string-or-integer)))))
    770774    (unless counter
    771       (setq *gensym-counter* (1+ (setq counter *gensym-counter*))))
     775      (with-lock-grabbed (*gensym-lock*)
     776        (setq *gensym-counter* (1+ (setq counter *gensym-counter*)))))
    772777    (make-symbol (%str-cat prefix (%integer-to-string counter)))))
    773778
Note: See TracChangeset for help on using the changeset viewer.