3 ms·
Isn't that a timing race? You're relying on the notification of "I'm done" getting there before the other thread tries to send. Write-and-panic has the advanta
by JulianMorrison 10y ago
Isn't that a timing race? You're relying on the notification of "I'm done" getting there before the other thread tries to send.
Write-and-panic has the advantage of being atomic. And you can catch a panic.
If you have a stoppable reader like that, maybe have it pull using a channel of channels. That is, consumer sends the producer "here is a one use unbuffered channel, please put an item in it" and then blocks waiting for the response.