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'.
This commit is contained in:
Ludovic Courtès 2019-06-03 16:24:31 +02:00
parent b7178c22bf
commit 89ceb86ad4
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 6 additions and 4 deletions

View File

@ -1083,17 +1083,19 @@ exception if it's already taken."
(close-port port) (close-port port)
#t) #t)
(define-syntax-rule (with-file-lock file exp ...) (define (call-with-file-lock file thunk)
"Wait to acquire a lock on FILE and evaluate EXP in that context."
(let ((port (lock-file file))) (let ((port (lock-file file)))
(dynamic-wind (dynamic-wind
(lambda () (lambda ()
#t) #t)
(lambda () thunk
exp ...)
(lambda () (lambda ()
(unlock-file port))))) (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'. ;;; Miscellaneous, aka. 'prctl'.