plugged a leak in drracket (thanks to Matthew for finding it!)

This commit is contained in:
Robby Findler 2010-11-26 19:31:48 -06:00
parent ee2b11630f
commit bc9a5e4b48
2 changed files with 31 additions and 15 deletions

View File

@ -734,8 +734,11 @@ is saved in the namespace, making the listening and information producing
namespace-specific.
@defproc[(planet-terse-register
[proc (-> (or/c 'download 'install 'docs-build 'finish) string? any/c)]
[namespace namespace? (current-namespace)]) void?]{
[proc (-> (or/c 'download 'install 'docs-build 'finish)
string?
any/c)]
[key symbol? (planet-terse-log-key-param)])
void?]{
Registers @racket[proc] as a function to be called when
@racket[planet-terse-log] is called with a matching namespace argument.
Note that @racket[proc] is called
@ -744,9 +747,19 @@ asynchronously (ie, on some thread other than the one calling @racket[planet-ter
@defproc[(planet-terse-log [id (or/c 'download 'install 'finish)]
[msg string?]
[namespace namespace? (current-namespace)]) void?]{
This function is called by PLaneT to announce when things are happening.
The namespace passed along is used to identify the procs to notify.
[key symbol? (planet-terse-log-key-param)]) void?]{
This function is called by PLaneT to announce when things are happening.
The namespace passed along is used to identify the procs to notify. This function
invokes all of the callbacks registered with @racket[key], and when PLaneT invokes it,
the @racket[key] argument is always @racket[(planet-terse-log-key-param)].
}
@defparam[planet-terse-log-key-param key symbol?]{
Holds the current value of the key used for getting and setting the @PLaneT logging information.
}
@defproc[(planet-terse-set-key [key symbol?]) void?]{
Equivalent to @racket[(planet-terse-log-key-param new-key)].
}
@section{Developing Packages for PLaneT}

View File

@ -12,13 +12,14 @@ seems little point to that).
|#
(provide planet-terse-register
(provide planet-terse-register
planet-terse-log
planet-terse-set-key)
planet-terse-set-key
planet-terse-log-key-param)
(define terse-log-message-chan (make-channel))
(define terse-log-proc-chan (make-channel))
(define terse-log-key-param (make-parameter (gensym)))
(define planet-terse-log-key-param (make-parameter (gensym)))
(define thd
(thread
@ -33,7 +34,7 @@ seems little point to that).
[id (list-ref msg 1)]
[str (list-ref msg 2)])
(for-each (lambda (eph)
(let ([proc (ephemeron-value eph)])
(let ([proc (weak-box-value eph)])
(when proc
(proc id str))))
(hash-ref procs registry '())))
@ -45,15 +46,17 @@ seems little point to that).
[proc (list-ref rp 1)])
(hash-update! procs
registry
(lambda (x) (cons (make-ephemeron registry proc) x))
(lambda (x) (cons (make-weak-box proc) x))
'())
(loop))))))))))
(define (planet-terse-log id str [key (terse-log-key-param)])
(sync (channel-put-evt terse-log-message-chan (list key id str))))
(define (planet-terse-log id str [key (planet-terse-log-key-param)])
(sync (channel-put-evt terse-log-message-chan (list key id str)))
(void))
(define (planet-terse-register proc [key (terse-log-key-param)])
(sync (channel-put-evt terse-log-proc-chan (list key proc))))
(define (planet-terse-register proc [key (planet-terse-log-key-param)])
(sync (channel-put-evt terse-log-proc-chan (list key proc)))
(void))
(define (planet-terse-set-key new-key)
(terse-log-key-param new-key))
(planet-terse-log-key-param new-key))