Hi. Is there any zero-capacity channels that alway...
# coroutines
k
Hi. Is there any zero-capacity channels that always can
send
without suspension? It seems
Channel(0)#send
will suspend unless any receivers are consuming values. It is okay if values will be lost when no receivers are consuming.
b
So you want a rendezvous channel that only facilitates a rendezvous initiated by the receiver (instead of the sender)?
j
Sounds like a conflated broadcast channel
d
Conflate!
Or just use
offer
.
đź‘Ť 2
e
You should use
offer
. then depending on channel capacity:
CONFLATED
-> offer always returns true, receiver is guaranteed to get the most recent value.
RENDEZVOUS
-> offer returns false when receiver is not waiting, the value is lost.
k
Thanks everyone,
RENDEZVOUS
Channel’s
offer
is exactly the one I was looking for! I was considered using conflated channels, but that channel has at most one buffer so receivers will be received value when start consuming.