guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04/09: syscalls: 'with-file-lock' expands to a call to 'call-with-file-l


From: guix-commits
Subject: 04/09: syscalls: 'with-file-lock' expands to a call to 'call-with-file-lock'.
Date: Wed, 5 Jun 2019 17:11:22 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 89ceb86ad415ea92450ebda60359a7ee0ec79eb6
Author: Ludovic Courtès <address@hidden>
Date:   Mon Jun 3 16:24:31 2019 +0200

    syscalls: 'with-file-lock' expands to a call to 'call-with-file-lock'.
    
    * 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 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 04fbebb..3af41f2 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -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 ...)))
+
 
 ;;;
 ;;; Miscellaneous, aka. 'prctl'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]