]> git.lizzy.rs Git - rust.git/commit
Rewrite channels yet again for upgradeability
authorAlex Crichton <alex@alexcrichton.com>
Thu, 9 Jan 2014 02:31:48 +0000 (18:31 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 12 Feb 2014 00:32:00 +0000 (16:32 -0800)
commit0a6b9219d180503254b55cfd14cdaf072fb35ac4
tree11ee47384b4ecaba8004ec5804c97db8782110e2
parent47ef20014c32443b12a122c0371a87f513830807
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.
39 files changed:
src/doc/guide-tasks.md
src/libextra/test.rs
src/libgreen/lib.rs
src/libnative/io/mod.rs
src/libnative/io/timer_helper.rs
src/librustuv/signal.rs
src/librustuv/uvio.rs
src/libstd/comm/mod.rs
src/libstd/comm/oneshot.rs [new file with mode: 0644]
src/libstd/comm/select.rs
src/libstd/comm/shared.rs [new file with mode: 0644]
src/libstd/comm/stream.rs [new file with mode: 0644]
src/libstd/io/signal.rs
src/libstd/prelude.rs
src/libstd/rt/mod.rs
src/libstd/rt/rtio.rs
src/libstd/rt/task.rs
src/libstd/rt/unwind.rs
src/libstd/run.rs
src/libstd/sync/mpmc_bounded_queue.rs
src/libstd/sync/mpsc_queue.rs
src/libstd/sync/spsc_queue.rs
src/libstd/task.rs
src/libsync/sync/mod.rs
src/libsync/sync/mutex.rs
src/libsync/sync/one.rs
src/test/bench/msgsend-pipes-shared.rs
src/test/bench/msgsend-pipes.rs
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-pfib.rs
src/test/bench/task-perf-linked-failure.rs
src/test/compile-fail/comm-not-freeze.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/task-comm-14.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-comm-6.rs
src/test/run-pass/task-comm-7.rs
src/test/run-pass/unique-send-2.rs
src/test/run-pass/unwind-resource.rs