mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
store: 'with-store' expands to a single procedure call.
* guix/store.scm (call-with-store): New procedure. (with-store): Write in terms of 'call-with-store'.
This commit is contained in:
parent
5c32857f91
commit
95207e70d5
1 changed files with 8 additions and 4 deletions
|
@ -602,19 +602,23 @@ (define (close-connection server)
|
|||
"Close the connection to SERVER."
|
||||
(close (store-connection-socket server)))
|
||||
|
||||
(define-syntax-rule (with-store store exp ...)
|
||||
"Bind STORE to an open connection to the store and evaluate EXPs;
|
||||
automatically close the store when the dynamic extent of EXP is left."
|
||||
(define (call-with-store proc)
|
||||
"Call PROC with an open store connection."
|
||||
(let ((store (open-connection)))
|
||||
(dynamic-wind
|
||||
(const #f)
|
||||
(lambda ()
|
||||
(parameterize ((current-store-protocol-version
|
||||
(store-connection-version store)))
|
||||
exp) ...)
|
||||
(proc store)))
|
||||
(lambda ()
|
||||
(false-if-exception (close-connection store))))))
|
||||
|
||||
(define-syntax-rule (with-store store exp ...)
|
||||
"Bind STORE to an open connection to the store and evaluate EXPs;
|
||||
automatically close the store when the dynamic extent of EXP is left."
|
||||
(call-with-store (lambda (store) exp ...)))
|
||||
|
||||
(define current-store-protocol-version
|
||||
;; Protocol version of the store currently used. XXX: This is a hack to
|
||||
;; communicate the protocol version to the build output port. It's a hack
|
||||
|
|
Loading…
Reference in a new issue