diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-01-08 18:31:48 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-02-11 16:32:00 -0800 |
| commit | 0a6b9219d180503254b55cfd14cdaf072fb35ac4 (patch) | |
| tree | 11ee47384b4ecaba8004ec5804c97db8782110e2 /src/libsync/sync | |
| parent | 47ef20014c32443b12a122c0371a87f513830807 (diff) | |
| download | rust-0a6b9219d180503254b55cfd14cdaf072fb35ac4.tar.gz rust-0a6b9219d180503254b55cfd14cdaf072fb35ac4.zip | |
Rewrite channels yet again for upgradeability
This, the Nth rewrite of channels, is not a rewrite of the core logic behind channels, but rather their API usage. In the past, we had the distinction between oneshot, stream, and shared channels, but the most recent rewrite dropped oneshots in favor of streams and shared channels. This distinction of stream vs shared has shown that it's not quite what we'd like either, and this moves the `std::comm` module in the direction of "one channel to rule them all". There now remains only one Chan and one Port. This new channel is actually a hybrid oneshot/stream/shared channel under the hood in order to optimize for the use cases in question. Additionally, this also reduces the cognitive burden of having to choose between a Chan or a SharedChan in an API. My simple benchmarks show no reduction in efficiency over the existing channels today, and a 3x improvement in the oneshot case. I sadly don't have a pre-last-rewrite compiler to test out the old old oneshots, but I would imagine that the performance is comparable, but slightly slower (due to atomic reference counting). This commit also brings the bonus bugfix to channels that the pending queue of messages are all dropped when a Port disappears rather then when both the Port and the Chan disappear.
Diffstat (limited to 'src/libsync/sync')
| -rw-r--r-- | src/libsync/sync/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsync/sync/mutex.rs | 2 | ||||
| -rw-r--r-- | src/libsync/sync/one.rs | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/libsync/sync/mod.rs b/src/libsync/sync/mod.rs index 0ac385ea1d1..7078f01945e 100644 --- a/src/libsync/sync/mod.rs +++ b/src/libsync/sync/mod.rs @@ -764,7 +764,7 @@ mod tests { use std::cast; use std::result; use std::task; - use std::comm::{SharedChan, Empty}; + use std::comm::Empty; /************************************************************************ * Semaphore tests @@ -1393,7 +1393,7 @@ mod tests { #[test] fn test_barrier() { let barrier = Barrier::new(10); - let (port, chan) = SharedChan::new(); + let (port, chan) = Chan::new(); for _ in range(0, 9) { let c = barrier.clone(); diff --git a/src/libsync/sync/mutex.rs b/src/libsync/sync/mutex.rs index f1a81d65c1d..3726528a5e9 100644 --- a/src/libsync/sync/mutex.rs +++ b/src/libsync/sync/mutex.rs @@ -531,7 +531,7 @@ mod test { } } - let (p, c) = SharedChan::new(); + let (p, c) = Chan::new(); for _ in range(0, N) { let c2 = c.clone(); native::task::spawn(proc() { inc(); c2.send(()); }); diff --git a/src/libsync/sync/one.rs b/src/libsync/sync/one.rs index 93d818b704d..a651f3b9d4c 100644 --- a/src/libsync/sync/one.rs +++ b/src/libsync/sync/one.rs @@ -137,7 +137,7 @@ mod test { static mut o: Once = ONCE_INIT; static mut run: bool = false; - let (p, c) = SharedChan::new(); + let (p, c) = Chan::new(); for _ in range(0, 10) { let c = c.clone(); spawn(proc() { |
