adjust online check syntax to try to fix a bug where renaming information
can get "stale" and cause DrRacket to deadlock (this commit just sets up some stuff to make one fix possible, but that fix doesn't seem to be working, so the actual fix is disabled (see comment in commit))
This commit is contained in:
parent
019e57b9d7
commit
a0ef78e97b
|
@ -128,7 +128,8 @@
|
|||
(list (handler-key handler)
|
||||
((handler-proc handler) expanded
|
||||
path
|
||||
the-source))))
|
||||
the-source
|
||||
orig-cust))))
|
||||
(log-info "expanding-place.rkt: 11 handlers finished")
|
||||
|
||||
(parameterize ([current-custodian orig-cust])
|
||||
|
|
|
@ -11,20 +11,25 @@
|
|||
|
||||
(define obj%
|
||||
(class (annotations-mixin object%)
|
||||
(init-field src)
|
||||
(init-field src orig-cust)
|
||||
(define trace '())
|
||||
|
||||
(define-values (remote local) (place-channel))
|
||||
(define table (make-hash))
|
||||
(thread
|
||||
(λ ()
|
||||
(with-handlers ((exn:fail? (λ (x) (eprintf "online-comp.rkt: thread failed ~a\n" (exn-message x)))))
|
||||
(let loop ()
|
||||
(define id/name (place-channel-get local))
|
||||
(define id (list-ref id/name 0))
|
||||
(define name (list-ref id/name 1))
|
||||
(define res ((hash-ref table id) name))
|
||||
(place-channel-put local res)))))
|
||||
|
||||
;; the hope is that changing the custodian like this
|
||||
;; shouldn't leak these threads, but it does seem to
|
||||
;; so for now we don't use it
|
||||
(parameterize (#;[current-custodian orig-cust])
|
||||
(thread
|
||||
(λ ()
|
||||
(with-handlers ((exn:fail? (λ (x) (eprintf "online-comp.rkt: thread failed ~a\n" (exn-message x)))))
|
||||
(let loop ()
|
||||
(define id/name (place-channel-get local))
|
||||
(define id (list-ref id/name 0))
|
||||
(define name (list-ref id/name 1))
|
||||
(define res ((hash-ref table id) name))
|
||||
(place-channel-put local res))))))
|
||||
|
||||
(define/override (syncheck:find-source-object stx)
|
||||
(and (equal? src (syntax-source stx))
|
||||
|
@ -51,7 +56,7 @@
|
|||
(define/public (get-trace) (reverse trace))
|
||||
(super-new)))
|
||||
|
||||
(define (go expanded path the-source)
|
||||
(define (go expanded path the-source orig-cust)
|
||||
(with-handlers ((exn:fail? (λ (x)
|
||||
(printf "~a\n" (exn-message x))
|
||||
(printf "---\n")
|
||||
|
@ -62,7 +67,9 @@
|
|||
(printf " ~s\n" x))
|
||||
(printf "===\n")
|
||||
(raise x))))
|
||||
(define obj (new obj% [src the-source]))
|
||||
(define obj (new obj%
|
||||
[src the-source]
|
||||
[orig-cust orig-cust]))
|
||||
(define-values (expanded-expression expansion-completed)
|
||||
(make-traversal (current-namespace)
|
||||
(get-init-dir path)))
|
||||
|
|
|
@ -110,7 +110,10 @@ all of the names in the tools library, for use defining keybindings
|
|||
|
||||
(proc-doc/names
|
||||
drracket:module-language-tools:add-online-expansion-handler
|
||||
(-> path-string? symbol? (-> (is-a?/c drracket:unit:definitions-text<%>) any/c any) void?)
|
||||
(-> path-string? symbol? (-> (is-a?/c drracket:unit:definitions-text<%>)
|
||||
any/c
|
||||
any)
|
||||
void?)
|
||||
(mod-path id local-handler)
|
||||
@{Registers a pair of procedures with DrRacket's online expansion machinery.
|
||||
|
||||
|
@ -121,11 +124,34 @@ all of the names in the tools library, for use defining keybindings
|
|||
the fully expanded object to that first procedure. (The procedure is called
|
||||
in the same context as the expansion process.)
|
||||
|
||||
Note that the thread that calls this procedure may be
|
||||
killed at anytime: DrRacket may kill it when the user types in the buffer
|
||||
The contract for that procedure is
|
||||
@racketblock[(-> syntax? path? any/c custodian?
|
||||
any)]
|
||||
There are three other arguments.
|
||||
|
||||
@itemize[
|
||||
@item{
|
||||
The @racket[path?] argument is the path that was the @racket[current-directory]
|
||||
when the code was expanded. This directory should be used as the
|
||||
@racket[current-directory] when resolving module paths obtained from
|
||||
the syntax object.}
|
||||
|
||||
@item{
|
||||
The third argument is the source object used in the syntax objects that
|
||||
come from the definitions window in DrRacket. It may be a path (if the file
|
||||
was saved), but it also might not be. Use @racket[equal?] to compare it
|
||||
with the @racket[syntax-source] field of syntax objects to determine if
|
||||
they come from the definitions window.}
|
||||
|
||||
@item{ Note that the thread that calls this procedure may be
|
||||
killed at any time: DrRacket may kill it when the user types in the buffer
|
||||
(in order to start a new expansion), but bizarro code may also create a separate
|
||||
thread during expansion that lurks around and then mutates arbitrary things.
|
||||
|
||||
Some code, however, should be longer running, surviving such custodian
|
||||
shutdowns. To support this, the procedure called in the separate place is
|
||||
supplied with a more powerful custodian that is not shut down. }]
|
||||
|
||||
The result of the procedure is expected to be something that can be sent
|
||||
across a @racket[place-channel], which is then sent back to the original
|
||||
place where DrRacket itself is running and passed to the @racket[local-handler]
|
||||
|
|
Loading…
Reference in New Issue
Block a user