Skip to content

Commit

Permalink
Actually use without-interrupts and rename macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ruricolist committed Mar 10, 2024
1 parent 8b72484 commit ad86eb5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions defer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
(execute-scope-guards (rest scope-guards))))
(values))

(defmacro unwind-protect* (protected &body cleanup)
(defmacro unwind-protect/without-interrupts (protected &body cleanup)
"Like `unwind-protect', but try to guarantee cleanup forms cannot be
interrupted."
#+sbcl
`(sb-sys:without-interrupts
(unwind-protect
(sb-sys:with-local-interrupts
(sb-sys:without-interrupts
,protected)
,@cleanup))
;; CCL at least guarantees no interrupts in cleanup. TODO Does
Expand All @@ -62,11 +62,11 @@ interrupted."
(with-unique-names (guarded-scope)
`(let* ((,guarded-scope (make-guarded-scope))
(*guarded-scope* ,guarded-scope))
(unwind-protect*
(multiple-value-prog1
(locally ,@body)
(setf (guard-scope-success ,guarded-scope) t))
(execute-scope-guards ,guarded-scope)))))
(unwind-protect/without-interrupts
(multiple-value-prog1
(locally ,@body)
(setf (guard-scope-success ,guarded-scope) t))
(execute-scope-guards ,guarded-scope)))))

(defmacro with-scope-guard ((&key (on :exit)) &body body)
(with-unique-names (guarded-scope)
Expand Down

0 comments on commit ad86eb5

Please sign in to comment.