collect multiple values at once
Opened this issue · 1 comments
dedbox commented
Sometimes I just want to flatten N
values into a single list and buffer any overflow for the next synchronization.
Currently throws an exception when given multiple values at once:
main.rkt> (define m (make-mediator))
main.rkt> (thread (λ () (for ([i 10]) (sync (say m i #t)))))
#<thread>
main.rkt> (sync (collect m 4))
; cons: arity mismatch;
; the expected number of arguments does not match the given number
; expected: 2
; given: 3
; arguments...:
; 3
; #t
; '()
dedbox commented
Another alternative: any number of values from N
senders.
> (sync (collect* m 4))
'((1 2) () (3) (4 5 6))
This could be used to implement the current behavior by checking each sub-list has length 1 and flattening the results.
There are a lot more variations:
- overflow: drop vs error, report vs silent
- sync: release senders immediately (
collect
) or all at once (quorum
)?