cs & io: fix shared byte strings over place channels

This commit is contained in:
Matthew Flatt 2019-04-30 17:33:18 -06:00
parent f5836d7a30
commit dcb0f422a9
3 changed files with 25 additions and 6 deletions

View File

@ -182,6 +182,19 @@
;; ----------------------------------------
(let ()
(define-values (in out) (place-channel))
(define (try v)
(place-channel-put in v)
(test #t eq? v (place-channel-get out)))
(try (shared-bytes 0))
(try (make-shared-bytes 10))
(try (make-shared-bytes 10 3)))
;; ----------------------------------------
(require (submod "place-utils.rkt" place-test-submod))
(test 0 p 0)

View File

@ -10,7 +10,7 @@
(for-each (lambda (arg)
(check who byte? arg))
args)
(apply #2%bytevector args))
(register-place-shared (apply #2%bytevector args)))
(define bytes? #2%bytevector?)
@ -29,11 +29,11 @@
(define/who make-shared-bytes
(case-lambda
[(n) (#2%make-bytevector n 0)]
[(n) (make-shared-bytes n 0)]
[(n b)
(check who exact-nonnegative-integer? n)
(check who byte? b)
(#2%make-bytevector n b)]))
(register-place-shared (#2%make-bytevector n b))]))
(define/who (list->bytes lst)
(check who

View File

@ -31,7 +31,10 @@
(symbol? v)
(and (or (string? v)
(bytes? v))
(or (not direct?) (immutable? v)))
(or (not direct?)
(immutable? v)
(and (bytes? v)
(place-shared? v))))
(null? v)
(and (pair? v)
(or (hash-ref graph v #f)
@ -60,7 +63,8 @@
(and (not direct?)
(or (cpointer? v)
(and (or (fxvector? v)
(flvector? v))
(flvector? v)
(bytes? v))
(place-shared? v))
(and (place-message? v)
((place-message-ref v) v)
@ -102,7 +106,9 @@
[(string? v)
(string->immutable-string v)]
[(bytes? v)
(bytes->immutable-bytes v)]
(if (place-shared? v)
v
(bytes->immutable-bytes v))]
[else
(unless graph (set! graph (make-hasheq)))
(cond