Skip to content

Commit b54ada5

Browse files
Change xref var to get-xref function; delete xref-ready-evt
The ready event, although not used, wasn't implemented correctly. Although moot now, better to set this up to work correctly if needed someday.
1 parent c5bee68 commit b54ada5

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

racket/commands/help.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
(->identifier how str stx->uri-string))
2929

3030
(define (stx->uri-string stx)
31+
(define xref (get-xref))
3132
(match (and xref (xref-binding->definition-tag xref stx 0))
3233
[(? tag? tag)
3334
(define-values (path anchor) (xref-tag->path+anchor xref tag))

racket/scribble.rkt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444

4545
(define/contract (binding->path+anchor stx)
4646
(-> identifier? (or/c #f (cons/c path-string? (or/c #f string?))))
47-
(let* ([tag (xref-binding->definition-tag xref stx 0)]
47+
(let* ([xref (get-xref)]
48+
[tag (xref-binding->definition-tag xref stx 0)]
4849
[p+a (and tag (tag->path+anchor xref tag))])
4950
p+a))
5051

@@ -72,7 +73,7 @@
7273

7374
(define/contract (identifier->bluebox stx)
7475
(-> identifier? (or/c #f string?))
75-
(match (xref-binding->definition-tag xref stx 0)
76+
(match (xref-binding->definition-tag (get-xref) stx 0)
7677
[(? tag? tag) (get-bluebox-string tag)]
7778
[_ #f]))
7879

@@ -169,7 +170,7 @@
169170
(let ([ht (exported-index-desc*-extras desc)])
170171
(or (hash-ref ht 'hidden? #f)
171172
(hash-ref ht 'constructor? #f))))))
172-
(for* ([entry (in-list (xref-index xref))]
173+
(for* ([entry (in-list (xref-index (get-xref)))]
173174
[desc (in-value (entry-desc entry))]
174175
#:when desc
175176
#:unless (hide-desc? desc)
@@ -181,7 +182,7 @@
181182
root)
182183

183184
(define (doc-trie-value desc term tag)
184-
(define-values (path anchor) (xref-tag->path+anchor xref tag))
185+
(define-values (path anchor) (xref-tag->path+anchor (get-xref) tag))
185186
(define (method-what)
186187
(cond
187188
[(method-tag? tag)

racket/xref.rkt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55

66
(require setup/xref)
77

8-
(provide xref
9-
xref-ready-evt)
8+
(provide get-xref)
109

11-
(define xref-ready-evt never-evt)
12-
(define xref (begin0 (load-collections-xref)
13-
(set! xref-ready-evt always-evt)))
10+
;; A single xref instance for all our modules to share.
11+
;;
12+
;; Will block safely until ready, if used from e.g. delay/thread or
13+
;; delay/idle (which, although we're not doing now, we've done before,
14+
;; and might do again someday).
15+
(define sema (make-semaphore 1))
16+
(define xref (call-with-semaphore sema load-collections-xref))
17+
(define (get-xref) (call-with-semaphore sema (λ () xref)))

0 commit comments

Comments
 (0)