Hacker News new | ask | show | jobs
by mmerickel 3697 days ago
I believe a channel can only have one receiver and one sender, no? So you can't share the channel between multiple workers.
1 comments

This is the case for spsc (single producer, single consumer) channels, but the example I posted is for a mpsc (multiple producer single consumer) channel. Any number of threads can push data into it, as the example shows!

Having multiple receivers is slightly more complex, and you can't use std::sync::mpsc (obviously) but they are also possible.