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'.master
parent
5c32857f91
commit
95207e70d5
|
@ -602,19 +602,23 @@ connection. Use with care."
|
||||||
"Close the connection to SERVER."
|
"Close the connection to SERVER."
|
||||||
(close (store-connection-socket server)))
|
(close (store-connection-socket server)))
|
||||||
|
|
||||||
(define-syntax-rule (with-store store exp ...)
|
(define (call-with-store proc)
|
||||||
"Bind STORE to an open connection to the store and evaluate EXPs;
|
"Call PROC with an open store connection."
|
||||||
automatically close the store when the dynamic extent of EXP is left."
|
|
||||||
(let ((store (open-connection)))
|
(let ((store (open-connection)))
|
||||||
(dynamic-wind
|
(dynamic-wind
|
||||||
(const #f)
|
(const #f)
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(parameterize ((current-store-protocol-version
|
(parameterize ((current-store-protocol-version
|
||||||
(store-connection-version store)))
|
(store-connection-version store)))
|
||||||
exp) ...)
|
(proc store)))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(false-if-exception (close-connection store))))))
|
(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
|
(define current-store-protocol-version
|
||||||
;; Protocol version of the store currently used. XXX: This is a hack to
|
;; 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
|
;; communicate the protocol version to the build output port. It's a hack
|
||||||
|
|
Reference in New Issue