[racket] Places, Channels as Events. Labeling Places.

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Dec 13 17:33:08 EST 2012

I think you want handle-evt, eg:

(sync (handle-evt p1 (lambda (x) (list p1 x))) ....)

Robby


On Thu, Dec 13, 2012 at 4:27 PM, Ray Racine <ray.racine at gmail.com> wrote:

> Using a Place or a Place-Channel as a sync event returns the value of a
> place-channel-get and not the Place itself.
>
> Most events return the actual `thing' which one sync'd on.  This is not
> true with places and channels, one gets the message itself.
>
> The conundrum is identification of which Place / Place-Channel actually
> fired.  Places themselves have no real mechanism supporting GUID labeling
> or even simple naming/labeling.   There is no (place-name my-place) or
> ability to assign an identifier upon creation.  There is documented support
> for Place and Place-Channel equality.  So one can work around all this at
> the app code level, i.e. implement their own labeling system for Places.
>
> However assuming a roll your own labeling system there is still
> the anonymity of a place / place-channel when used as a sync event issue.
>
> (let ((msg (sync pl-1 pl-2 pl-3))))
>    ;; no idea from which place msg came from, unless explicitly recorded
> in the msg itself.
>    ;; e.g. (Msg-sender msg) -> my home brewed Place-GUID
>
> Compare and contrast with ports used as an event.  A port used as a sync
> event results in the port itself upon which one can do whatever this
> knowledge.  For example, I might opt *not* to read the port as this time,
> even unilaterally close it without reading.
>
> Consider the following parallel, asynchronous request/response idiom.
>
> Given N request msgs and P places, issue one request message per ready
> place. (Ready in the sense it is not processing a request.)
>
> I want something like
>
> (let loop ((msgs ...))
>   ...
>   (let ((ready-place (sync p1 p2 p3)))
>         (process-response (place-channel-get ready-place))
>         (process-request ready-place (car msgs))
>         (loop (cdr msgs))
>
> How would one approach something like this given `sync' not returning the
> ready place but the received msg from some anonymous place which was ready.
>
>
>
> Thanks,
>
> Ray
>
>
>
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121213/e7a4c871/attachment.html>

Posted on the users mailing list.