To make it clear here is what i have in mind:

#lang racket

;; dummy function, just remplace by A
(define (do-stuff shared-data data-length)
  (values
   (make-bytes data-length 65)
   data-length))

(define p
  (place ch
         (define shared-data (place-channel-get ch))
         (let loop ()
           (define data-length (place-channel-get ch))
           (define-values (new-data new-data-length) (do-stuff shared-data 
data-length))
           (bytes-copy! shared-data 0 new-data 0 new-data-length)
           (place-channel-put ch new-data-length)
           (loop))))

(module+ main
  (define shared-data (make-shared-bytes 10 66))
  (place-channel-put p shared-data)
  (place-channel-put p 5)
  (place-channel-get p) ;; 5
  (printf "~a\n" shared-data)  ;; AAAAABBBBB
  (place-channel-put p 7)
  (place-channel-get p) ;; 7
  (printf "~a\n" shared-data)) ;; AAAAAAABBB

> But you would still need to copy the mutable byte string (returned by various 
> byte string functions) to the shared byte string you create with 
> make-shared-bytes, right? So, a byte string would still be copied.

Yes

> As someone suggested earlier, I could use read-bytes! and read directly into 
> a byte string created by make-shared-bytes. Then I *think* the cost to "send" 
> it to the worker place is minimal (maybe just sending a pointer). That would 
> require some buffer bookkeeping to split lines, etc., but the workers would 
> still need to copy their resulting byte strings to the output place.

Yes

> Maybe I'm being overprotective, but my hunch is that I need the output place 
> to serialize access to the output file vs. having the worker places write 
> directly to it, but if Racket serializes access to the output port, maybe I 
> can skip that.

According to the doc it seem you can't pass output-file-port.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to