master
Matthew Butterick 5 years ago
parent 481f436ff1
commit c7e5a4810e

@ -9,9 +9,9 @@
(define (make-runner program [calling-thd (current-thread)]) (define (make-runner program [calling-thd (current-thread)])
(thread (λ () (thread (λ ()
(define regs (string->regs program)) (define regs (string->regs program))
(define (maybe-enlarge-regs len) (define (maybe-enlarge-regs ptr)
(unless (< len (vector-length regs)) (unless (< ptr (vector-length regs))
(define newvec (make-vector (add1 len) 0)) (define newvec (make-vector (add1 ptr) 0))
(vector-copy! newvec 0 regs) (vector-copy! newvec 0 regs)
(set! regs newvec)) (set! regs newvec))
regs) regs)
@ -64,10 +64,8 @@
(define thd (match program-or-thread (define thd (match program-or-thread
[(? thread? thd) thd] [(? thread? thd) thd]
[program (make-runner program)])) [program (make-runner program)]))
(let loop ([acc null]) (for/list ([val (in-producer thread-receive 'done)])
(match (thread-receive) val))
['done (reverse acc)]
[msg (loop (cons msg acc))])))
(check-equal? (check-equal?