@mike.hoarn has joined the channel
what’s The Right Way™©®
to loop over (thread-receive)
and break out of the loop on a special exit value returned fro (thread-receive)
? I was doing: (thread (λ ()
(for ( [i (in-naturals)]
[params (thread-receive)])
(define query (first params))
(define records (second params))
(apply query-exec (CONN) query (flatten records))))))
But since (thread-receive)
receives a list, params only binds to the first item. I’m also not convinced that this will call (thread-receive)
with every iteration
@khepin Use in-producer
with a stop
value. http://docs.racket-lang.org/reference/sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._in-producer%29%29
That …. looks perfect!
thanks
If (thread-recieve)
then produces a list, and you want to iterate over the list as well, do something like this using for*
: (for* ([params (in-producer thread-receieve my-stop-value)]
[param (in-list params)])
....)
Thanks!
@krystal.maughan has joined the channel