setup/dirs et al.: thread-safe promises
Use `delay/sync` instead of `delay`.
This commit is contained in:
parent
7ac92703dc
commit
d96bfb6e29
|
@ -221,11 +221,11 @@
|
||||||
(loop hi (* 2 offset)))))))
|
(loop hi (* 2 offset)))))))
|
||||||
|
|
||||||
(define get-min-seconds
|
(define get-min-seconds
|
||||||
(let ([d (delay (find-extreme-date-seconds (current-seconds) -1))])
|
(let ([d (delay/sync (find-extreme-date-seconds (current-seconds) -1))])
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(force d))))
|
(force d))))
|
||||||
(define get-max-seconds
|
(define get-max-seconds
|
||||||
(let ([d (delay (find-extreme-date-seconds (current-seconds) 1))])
|
(let ([d (delay/sync (find-extreme-date-seconds (current-seconds) 1))])
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(force d))))
|
(force d))))
|
||||||
|
|
||||||
|
|
|
@ -18,18 +18,19 @@
|
||||||
;; config: definitions
|
;; config: definitions
|
||||||
|
|
||||||
(define config-table
|
(define config-table
|
||||||
(delay (let ([d (find-config-dir)])
|
(delay/sync
|
||||||
(if d
|
(let ([d (find-config-dir)])
|
||||||
(let ([p (build-path d "config.rktd")])
|
(if d
|
||||||
(if (file-exists? p)
|
(let ([p (build-path d "config.rktd")])
|
||||||
(call-with-input-file*
|
(if (file-exists? p)
|
||||||
p
|
(call-with-input-file*
|
||||||
(lambda (in)
|
p
|
||||||
(call-with-default-reading-parameterization
|
(lambda (in)
|
||||||
(lambda ()
|
(call-with-default-reading-parameterization
|
||||||
(read in)))))
|
(lambda ()
|
||||||
#hash()))
|
(read in)))))
|
||||||
#hash()))))
|
#hash()))
|
||||||
|
#hash()))))
|
||||||
|
|
||||||
(define (to-path l)
|
(define (to-path l)
|
||||||
(cond [(string? l) (simplify-path (complete-path (string->path l)))]
|
(cond [(string? l) (simplify-path (complete-path (string->path l)))]
|
||||||
|
@ -45,7 +46,7 @@
|
||||||
(find-main-collects))]))
|
(find-main-collects))]))
|
||||||
|
|
||||||
(define-syntax-rule (define-config name key wrap)
|
(define-syntax-rule (define-config name key wrap)
|
||||||
(define name (delay
|
(define name (delay/sync
|
||||||
(wrap
|
(wrap
|
||||||
(hash-ref (force config-table) key #f)))))
|
(hash-ref (force config-table) key #f)))))
|
||||||
|
|
||||||
|
@ -104,7 +105,9 @@
|
||||||
(combine-search (force config:collects-search-dirs)
|
(combine-search (force config:collects-search-dirs)
|
||||||
(list (find-collects-dir))))
|
(list (find-collects-dir))))
|
||||||
(define user-collects-dir
|
(define user-collects-dir
|
||||||
(delay (simplify-path (build-path (find-system-path 'addon-dir) (get-installation-name) "collects"))))
|
(delay/sync (simplify-path (build-path (find-system-path 'addon-dir)
|
||||||
|
(get-installation-name)
|
||||||
|
"collects"))))
|
||||||
(define (find-user-collects-dir)
|
(define (find-user-collects-dir)
|
||||||
(force user-collects-dir))
|
(force user-collects-dir))
|
||||||
(define (get-collects-search-dirs)
|
(define (get-collects-search-dirs)
|
||||||
|
@ -139,7 +142,9 @@
|
||||||
(define-finder provide config:id id get-false default)
|
(define-finder provide config:id id get-false default)
|
||||||
(provide user-id)
|
(provide user-id)
|
||||||
(define user-dir
|
(define user-dir
|
||||||
(delay (simplify-path (build-path (find-system-path 'addon-dir) (get-installation-name) user-default))))
|
(delay/sync (simplify-path (build-path (find-system-path 'addon-dir)
|
||||||
|
(get-installation-name)
|
||||||
|
user-default))))
|
||||||
(define (user-id)
|
(define (user-id)
|
||||||
(force user-dir)))]
|
(force user-dir)))]
|
||||||
[(_ provide config:id id user-id config:search-id search-id default)
|
[(_ provide config:id id user-id config:search-id search-id default)
|
||||||
|
@ -165,7 +170,7 @@
|
||||||
#'(begin
|
#'(begin
|
||||||
(provide id)
|
(provide id)
|
||||||
(define dir
|
(define dir
|
||||||
(delay
|
(delay/sync
|
||||||
(or (force config:id) (get-default))))
|
(or (force config:id) (get-default))))
|
||||||
(define (id)
|
(define (id)
|
||||||
(force dir))))]
|
(force dir))))]
|
||||||
|
@ -174,7 +179,7 @@
|
||||||
#'(begin
|
#'(begin
|
||||||
(provide id)
|
(provide id)
|
||||||
(define dir
|
(define dir
|
||||||
(delay
|
(delay/sync
|
||||||
(or (force config:id)
|
(or (force config:id)
|
||||||
(let ([p (find-collects-dir)])
|
(let ([p (find-collects-dir)])
|
||||||
(and p (simplify-path (build-path p 'up default)))))))
|
(and p (simplify-path (build-path p 'up default)))))))
|
||||||
|
@ -188,7 +193,7 @@
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
;; "doc"
|
;; "doc"
|
||||||
|
|
||||||
(define delayed-#f (delay #f))
|
(define delayed-#f (delay/sync #f))
|
||||||
|
|
||||||
(provide find-doc-dir
|
(provide find-doc-dir
|
||||||
find-user-doc-dir
|
find-user-doc-dir
|
||||||
|
@ -280,7 +285,7 @@
|
||||||
|
|
||||||
(provide find-dll-dir)
|
(provide find-dll-dir)
|
||||||
(define dll-dir
|
(define dll-dir
|
||||||
(delay
|
(delay/sync
|
||||||
(case (system-type)
|
(case (system-type)
|
||||||
[(windows)
|
[(windows)
|
||||||
;; Extract "lib" location from binary:
|
;; Extract "lib" location from binary:
|
||||||
|
|
|
@ -5,18 +5,19 @@
|
||||||
(provide variant-suffix)
|
(provide variant-suffix)
|
||||||
|
|
||||||
(define plain-mz-is-cgc?
|
(define plain-mz-is-cgc?
|
||||||
(delay (let* ([dir (find-console-bin-dir)]
|
(delay/sync
|
||||||
[exe (cond [(eq? 'windows (system-type)) "Racket.exe"]
|
(let* ([dir (find-console-bin-dir)]
|
||||||
[(equal? #".dll" (system-type 'so-suffix))
|
[exe (cond [(eq? 'windows (system-type)) "Racket.exe"]
|
||||||
;; in cygwin so-suffix is ".dll"
|
[(equal? #".dll" (system-type 'so-suffix))
|
||||||
"racket.exe"]
|
;; in cygwin so-suffix is ".dll"
|
||||||
[else "racket"])]
|
"racket.exe"]
|
||||||
[f (build-path dir exe)])
|
[else "racket"])]
|
||||||
(and (file-exists? f)
|
[f (build-path dir exe)])
|
||||||
(with-input-from-file f
|
(and (file-exists? f)
|
||||||
(lambda ()
|
(with-input-from-file f
|
||||||
(regexp-match? #rx#"bINARy tYPe:..c"
|
(lambda ()
|
||||||
(current-input-port))))))))
|
(regexp-match? #rx#"bINARy tYPe:..c"
|
||||||
|
(current-input-port))))))))
|
||||||
|
|
||||||
(define (variant-suffix variant cased?)
|
(define (variant-suffix variant cased?)
|
||||||
(let ([r (case variant
|
(let ([r (case variant
|
||||||
|
|
Loading…
Reference in New Issue
Block a user