> On 06 15 19, at 8:31 AM, Robby Findler <ro...@cs.northwestern.edu> wrote:
> A standard way to work with this is to send a channel over in the
> first communication and then the communication that's specific to that
> initial request happens on that channel. The precise way you set this
> up depends on what invariants of the communication you want. Like, you
> can create a new thread and just do all the communication there

And here's a threaded version, which I agree is neater, because by closing over 
each worker channel, the threads make other channel-tracking housekeeping 

#lang racket
(require racket/place)
(provide main)

(define (main)
  (define loopback-p
    (place lch
           (let loop ()
             (define wp (place-channel-get lch))
             (thread (λ () (let loop ()
                             (place-channel-put wp (place-channel-get wp))
  (define worker-ps
    (for/list ([i (in-range (processor-count))])
      (place wch
             (let make-request ([count 1])
               (define countout (place-channel-put/get wch count))
               (displayln (format "worker request ~a:~a got response ~a:~a ~a"
                                  0 count 0 countout
                                  (if (eq? count countout) "" "### fail")))
               (make-request (add1 count))))))
  (for ([worker-p (in-list worker-ps)])
    (place-channel-put loopback-p worker-p))
  (map place-wait worker-ps))

You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to