[racket] Detecting that a place channel is unreachable

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Sat Dec 7 13:10:37 EST 2013

Ok, I'll file a low priority feature request then and just make sure I
manually turn it off.

On Sat, Dec 7, 2013 at 9:45 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> You're right: the implementation has that kind of information (for
> non-distributed channels), but it's significant work to add a trigger.
> At Fri, 6 Dec 2013 23:53:04 -0800, Eric Dobson wrote:
>> Is there a way to determine if a place channel is unreachable? My
>> experiments with will executors seem to show that they trigger even if
>> the place channel is reachable from another place. Is there a way to
>> determine that all other places don't have access to the value, I
>> assume that it has to be possible because otherwise memory would leak,
>> but maybe getting triggers based of of it would be hard.
>> My goal is to have two places sharing a channel, and one stop sending
>> messages across if the other one is provable not listening. I can make
>> it so that it can turn it off manual, but I'm looking to see if I can
>> get it to work if the listener just lets the channel get gc'd.
>> Testing program:
>> #lang racket/base
>> (require racket/place)
>> (define (holder)
>>   (place chan
>>     (let loop ([v #f])
>>       (define v2 (sync chan))
>>       (place-channel-put chan v)
>>       (collect-garbage)
>>       (loop v2))))
>> (module+ main
>>   (define other (holder))
>>   (define exec (make-will-executor))
>>   (define exec-thread
>>     (thread
>>       (lambda ()
>>         (let loop ()
>>           (will-execute exec)
>>           (loop)))))
>>   (define in
>>     (let-values ([(in out) (place-channel)])
>>       (place-channel-put other out)
>>       (sync other)
>>       (will-register exec out
>>         (lambda (v) (printf "~a was deleted~n" v)))
>>       in))
>>   (collect-garbage)
>>   ;; Let will execute
>>   (sleep 1))
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users

Posted on the users mailing list.