syscalls: 'with-file-lock' expands to a call to 'call-with-file-lock'.
authorLudovic Courtès <ludo@gnu.org>
Mon, 3 Jun 2019 14:24:31 +0000 (16:24 +0200)
committerLudovic Courtès <ludo@gnu.org>
Wed, 5 Jun 2019 21:10:36 +0000 (23:10 +0200)
* guix/build/syscalls.scm (call-with-file-lock): New procedure.
(with-file-lock): Expand to a call to 'call-with-file-lock'.

guix/build/syscalls.scm

index 04fbebb..3af41f2 100644 (file)
@@ -1083,17 +1083,19 @@ exception if it's already taken."
   (close-port port)
   #t)
 
-(define-syntax-rule (with-file-lock file exp ...)
-  "Wait to acquire a lock on FILE and evaluate EXP in that context."
+(define (call-with-file-lock file thunk)
   (let ((port (lock-file file)))
     (dynamic-wind
       (lambda ()
         #t)
-      (lambda ()
-        exp ...)
+      thunk
       (lambda ()
         (unlock-file port)))))
 
+(define-syntax-rule (with-file-lock file exp ...)
+  "Wait to acquire a lock on FILE and evaluate EXP in that context."
+  (call-with-file-lock file (lambda () exp ...)))
+
 \f
 ;;;
 ;;; Miscellaneous, aka. 'prctl'.