From dad706a5bf44f868b05ba78328eeee1885aa1925 Mon Sep 17 00:00:00 2001 From: Avril Date: Thu, 11 Apr 2019 22:34:45 +0100 Subject: [PATCH] added with() --- cl-box.lisp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cl-box.lisp b/cl-box.lisp index 474fb0b..35902c1 100644 --- a/cl-box.lisp +++ b/cl-box.lisp @@ -60,7 +60,15 @@ (<- () (<-! ,name))) ,@things) (<-! ,name))))) - + +(defmacro with (box &body things) + (let ((name (gensym))) + `(let ((,name ,box)) + (bt:with-lock-held ((box-lock ,name)) + (flet ((-> (thing) (->! ,name thing)) + (<- () (<-! ,name))) + ,@things))))) + )) (defun test ()