Changeset 15145
- Timestamp:
- Dec 17, 2011, 9:24:51 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/source/level-1/l1-lisp-threads.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/level-1/l1-lisp-threads.lisp
r14748 r15145 1021 1021 (defvar *enable-automatic-termination* t) 1022 1022 1023 (defstatic *termination-functions-lock* (make-lock)) 1024 (defstatic *termination-functions* (make-hash-table :test #'eq :lock-free nil)) 1025 1026 (defun register-termination-function (f) 1027 (with-lock-grabbed (*termination-functions-lock*) 1028 (without-interrupts 1029 (incf (gethash f *termination-functions* 0))))) 1030 1031 (defun deregister-termination-function (f) 1032 (with-lock-grabbed (*termination-functions-lock*) 1033 (without-interrupts 1034 (let* ((count (gethash f *termination-functions*))) 1035 (when count 1036 (if (eql 0 (decf count)) 1037 (remhash f *termination-functions*) 1038 (setf (gethash f *termination-functions*) count))))))) 1039 1023 1040 (defun terminate-when-unreachable (object &optional (function 'terminate)) 1024 1041 "The termination mechanism is a way to have the garbage collector run a … … 1032 1049 (population *termination-population*)) 1033 1050 (without-interrupts 1051 (register-termination-function function) 1034 1052 (with-lock-grabbed (*termination-population-lock*) 1035 1053 (atomic-push-uvector-cell population population.data new-cell))) … … 1047 1065 (if (not existed) 1048 1066 (return) 1049 (funcall (cdr cell) (car cell)))))))) 1067 (let* ((f (cdr cell))) 1068 (deregister-termination-function f) 1069 (funcall f (car cell))))))))) 1050 1070 1051 1071 (defun cancel-terminate-when-unreachable (object &optional (function nil function-p)) … … 1066 1086 (or (null function-p) 1067 1087 (eq function f))) 1088 (deregister-termination-function f) 1068 1089 (if prev 1069 1090 (setf (cdr prev) (cdr spine))
Note:
See TracChangeset
for help on using the changeset viewer.
