Re:Rust: learning how to share a queue between threads
by dbeck74 on Saturday May 07, 2016 @04:01AM
(#11648787)
What your link shows is the usage of the channels. My post was about how to actually implement a similar thing.
Re:Rust: learning how to share a queue between threads
by mmerickel on Friday May 06, 2016 @07:31PM
(#11647478)
I believe a channel can only have one receiver and one sender, no? So you can't share the channel between multiple workers.
Re:Rust: learning how to share a queue between threads
by yarper on Friday May 06, 2016 @08:18PM
(#11647674)
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.
This is how you share a queue between threads, the title is super-clickbait. It doesn't seem a surprise that stdlib doesn't have a circular buffer, I have no idea what it'd be used for?