From bc9a5e4b4871dd0d74e55545a36cb8bf39e04d7a Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Fri, 26 Nov 2010 19:31:48 -0600 Subject: [PATCH] plugged a leak in drracket (thanks to Matthew for finding it!) --- collects/planet/planet.scrbl | 23 ++++++++++++++++++----- collects/planet/terse-info.rkt | 23 +++++++++++++---------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/collects/planet/planet.scrbl b/collects/planet/planet.scrbl index 31d0e87e7c..fd3c4fee09 100644 --- a/collects/planet/planet.scrbl +++ b/collects/planet/planet.scrbl @@ -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} diff --git a/collects/planet/terse-info.rkt b/collects/planet/terse-info.rkt index 6c0a212e41..51519fb078 100644 --- a/collects/planet/terse-info.rkt +++ b/collects/planet/terse-info.rkt @@ -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))