It’s interesting that even with Rust’s minimal standard library, there’s a bit of a “urllibN” situation with the concurrency stuff, with crossbeam-* and parking_lot :)
use crossbeam_channel as channel;
// Create a non-buffered channel.
let (tx, rx) = channel::unbounded();
// Create a buffered channel with a capcity of one.
let (s, r) = channel::bounded(1);
[...]
The first comment should be Create a buffered channel of unlimited capacity.. As you explain above this point, it would have to block when you send if it were unbuffered.
One of the biggest griefs in Go is that channels and IO are not composable in a select statement. For example this is not possible:
select {
case msg := <-myChan:
case msg := <-myFile.Read():
}
Instead, the file reader has to be wrapped in a goroutine and then forwarded to a channel. Then make sure to handle the file closing and shutdown the goroutine properly. I am aware that there are implementation details that make this difficult but since Go went to the trouble of implementing the NxM multiplexing, it’s a missed opportunity to make communication patterns very simple.
Huh, so looks like
crossbeam-channelis a successor tochan. Good to know.It’s interesting that even with Rust’s minimal standard library, there’s a bit of a “urllibN” situation with the concurrency stuff, with crossbeam-* and parking_lot :)
Minor correction in one example:
The first comment should be
Create a buffered channel of unlimited capacity.. As you explain above this point, it would have to block when you send if it were unbuffered.Do you mean this with regard to the Go example? I think you’re right though and I’ll make that fix later.
I meant in the first crossbeam-channel example.
One of the biggest griefs in Go is that channels and IO are not composable in a select statement. For example this is not possible:
Instead, the file reader has to be wrapped in a goroutine and then forwarded to a channel. Then make sure to handle the file closing and shutdown the goroutine properly. I am aware that there are implementation details that make this difficult but since Go went to the trouble of implementing the NxM multiplexing, it’s a missed opportunity to make communication patterns very simple.