[rust-dev] Many-to-many channels

2014-10-04 Thread Calder Coalson
Hi, First, thanks for all your hard work, and for such a wonderful language! I'm quite new to Rust, but so far I've found it a real pleasure to work (and think) in. I did run into one small hitch with the standard library recently. I'm writing some multithreaded code that lends itself naturally

Re: [rust-dev] Many-to-many channels

2014-10-04 Thread Peter Marheine
Is there a particular reason you need a Channel rather than some other primitive? If not, sync::mpmc_bounded_queue will probably do what you're looking for. On Sat, Oct 4, 2014 at 12:59 PM, Calder Coalson caldercoal...@gmail.com wrote: Hi, First, thanks for all your hard work, and for such a

Re: [rust-dev] Many-to-many channels

2014-10-04 Thread Calder Coalson
That's exactly what I was looking for, thanks! Out of curiosity, why are Rust channels built on top of MPSC queues rather than MPMC queues? On Sat, Oct 4, 2014 at 12:06 PM, Peter Marheine pe...@taricorp.net wrote: Is there a particular reason you need a Channel rather than some other

Re: [rust-dev] Many-to-many channels

2014-10-04 Thread Calder Coalson
On closer inspection, mpmc_bounded_queues aren't quite what I want. I want consumers to block if the queue is empty rather than returning None. On Sat, Oct 4, 2014 at 12:21 PM, Calder Coalson caldercoal...@gmail.com wrote: That's exactly what I was looking for, thanks! Out of curiosity, why

Re: [rust-dev] Many-to-many channels

2014-10-04 Thread Evan G
Couldn't you just implement that with a loop and a match statement? On Sat, Oct 4, 2014 at 4:25 PM, Calder Coalson caldercoal...@gmail.com wrote: On closer inspection, mpmc_bounded_queues aren't quite what I want. I want consumers to block if the queue is empty rather than returning None. On

Re: [rust-dev] Many-to-many channels

2014-10-04 Thread Sean McArthur
On Sat, Oct 4, 2014 at 1:27 PM, Evan G eg1...@gmail.com wrote: Couldn't you just implement that with a loop and a match statement? Wouldn't that just make the process burn cpu, instead of being able to allow other threads to work? ___ Rust-dev

Re: [rust-dev] Many-to-many channels

2014-10-04 Thread Zaven Muradyan
On 10/04/2014 01:37 PM, Sean McArthur wrote: Wouldn't that just make the process burn cpu, instead of being able to allow other threads to work? I would think so, yes. From what I can tell, `std::comm` channels do blocking by using `std::task::deschedule`, along with some internal housekeeping

Re: [rust-dev] Many-to-many channels

2014-10-04 Thread Evan G
Ahh that makes sense. Thanks both of you. I had an inkling that it was more complicated then I thought, but I wasn't sure. On Sat, Oct 4, 2014 at 6:22 PM, Zaven Muradyan za...@skepsi.me wrote: On 10/04/2014 01:37 PM, Sean McArthur wrote: Wouldn't that just make the process burn cpu, instead

Re: [rust-dev] Many-to-many channels

2014-10-04 Thread Calder Coalson
What Sean said. On Sat, Oct 4, 2014 at 1:37 PM, Sean McArthur smcart...@mozilla.com wrote: On Sat, Oct 4, 2014 at 1:27 PM, Evan G eg1...@gmail.com wrote: Couldn't you just implement that with a loop and a match statement? Wouldn't that just make the process burn cpu, instead of being able