From def70bc521a71b3bfa8d8b0bb982bbcd1743bd22 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 27 Jul 2022 08:49:15 -0500 Subject: [refactor] to get rid of finalizers. [add] pre-exit-hooks --- src/pre-exit-hooks.lisp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/pre-exit-hooks.lisp (limited to 'src/pre-exit-hooks.lisp') diff --git a/src/pre-exit-hooks.lisp b/src/pre-exit-hooks.lisp new file mode 100644 index 0000000..42e4195 --- /dev/null +++ b/src/pre-exit-hooks.lisp @@ -0,0 +1,16 @@ +;;; pre-exit-hooks.lisp + +(in-package :wheelwork) + +(defvar *pre-exit-hooks* (make-hash-table)) + +(defun pre-exit-hook-exists-p (tag) + (gethash tag *pre-exit-hooks*)) + +(defun pre-exit-hook (tag thunk) + (setf (gethash tag *pre-exit-hooks*) + thunk)) + +(defun pre-exit-hooks () + (loop for thunk being the hash-value of *pre-exit-hooks* + do (funcall thunk))) -- cgit v1.2.3