Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: Second pass stabilization for comm #20273

Merged
merged 4 commits into from
Jan 2, 2015

Conversation

alexcrichton
Copy link
Member

This commit is a second pass stabilization for the std::comm module,
performing the following actions:

  • The entire std::comm module was moved under std::sync::mpsc. This movement
    reflects that channels are just yet another synchronization primitive, and
    they don't necessarily deserve a special place outside of the other
    concurrency primitives that the standard library offers.
  • The send and recv methods have all been removed.
  • The send_opt and recv_opt methods have been renamed to send and recv.
    This means that all send/receive operations return a Result now indicating
    whether the operation was successful or not.
  • The error type of send is now a SendError to implement a custom error
    message and allow for unwrap(). The error type contains an into_inner
    method to extract the value.
  • The error type of recv is now RecvError for the same reasons as send.
  • The TryRecvError and TrySendError types have had public reexports removed
    of their variants and the variant names have been tweaked with enum
    namespacing rules.
  • The Messages iterator is renamed to Iter

This functionality is now all #[stable]:

  • Sender
  • SyncSender
  • Receiver
  • std::sync::mpsc
  • channel
  • sync_channel
  • Iter
  • Sender::send
  • Sender::clone
  • SyncSender::send
  • SyncSender::try_send
  • SyncSender::clone
  • Receiver::recv
  • Receiver::try_recv
  • Receiver::iter
  • SendError
  • RecvError
  • TrySendError::{mod, Full, Disconnected}
  • TryRecvError::{mod, Empty, Disconnected}
  • SendError::into_inner
  • TrySendError::into_inner

This is a breaking change due to the modification of where this module is
located, as well as the changing of the semantics of send and recv. Most
programs just need to rename imports of std::comm to std::sync::mpsc and
add calls to unwrap after a send or a receive operation.

[breaking-change]

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member Author

This is temporarily rebased on #20157 due to the high number of conflicts, the only relevant commit is the last one.

@flaper87
Copy link
Contributor

@alexcrichton you may also want to add RacyCell in the things to mark in this PR. I believe it's still experimental as we still don't know if the current implemented methods are the ones we'd like to keep around. However, I'd probably move it to stdy::sync instead of keeping it in std::sync::comm

@alexcrichton
Copy link
Member Author

I've updated this by removing all reexports in std::sync and renaming the comm module to mpsc. @aturon and I discussed and we think that this should allow for more channel implementations to be added in the future and it clearly spells out what the channel implementation is supposed to be used for.

@flaper87 I don't think RacyCell is public (and I'd like to keep it that way), so we don't have to worry about it too much during staiblization.

@alexcrichton alexcrichton force-pushed the second-pass-comm branch 2 times, most recently from 248acaf to 48ed934 Compare December 29, 2014 08:24
@flaper87
Copy link
Contributor

@alexcrichton yeah, it isn't and shouldn't be public. I thought we wanted to also stabilize our internal types too. However, I still think we should move it to std::sync, it could be used in other places in sync instead of things like Packet

alexcrichton and others added 3 commits December 29, 2014 08:58
This commit is an implementation of [RFC 503][rfc] which is a stabilization
story for the prelude. Most of the RFC was directly applied, removing reexports.
Some reexports are kept around, however:

* `range` remains until range syntax has landed to reduce churn.
* `Path` and `GenericPath` remain until path reform lands. This is done to
  prevent many imports of `GenericPath` which will soon be removed.
* All `io` traits remain until I/O reform lands so imports can be rewritten all
  at once to `std::io::prelude::*`.

This is a breaking change because many prelude reexports have been removed, and
the RFC can be consulted for the exact list of removed reexports, as well as to
find the locations of where to import them.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md
[breaking-change]

Closes rust-lang#20068
Now that it's been removed from the prelude, we need to treat things differently.

Fixes rust-lang#17967
@aturon
Copy link
Member

aturon commented Dec 29, 2014

OK, I've reviewed this and largely looks good, but I had some concerns about some of the new error types. Once those are addressed, r=me.

This commit is a second pass stabilization for the `std::comm` module,
performing the following actions:

* The entire `std::comm` module was moved under `std::sync::mpsc`. This movement
  reflects that channels are just yet another synchronization primitive, and
  they don't necessarily deserve a special place outside of the other
  concurrency primitives that the standard library offers.
* The `send` and `recv` methods have all been removed.
* The `send_opt` and `recv_opt` methods have been renamed to `send` and `recv`.
  This means that all send/receive operations return a `Result` now indicating
  whether the operation was successful or not.
* The error type of `send` is now a `SendError` to implement a custom error
  message and allow for `unwrap()`. The error type contains an `into_inner`
  method to extract the value.
* The error type of `recv` is now `RecvError` for the same reasons as `send`.
* The `TryRecvError` and `TrySendError` types have had public reexports removed
  of their variants and the variant names have been tweaked with enum
  namespacing rules.
* The `Messages` iterator is renamed to `Iter`

This functionality is now all `#[stable]`:

* `Sender`
* `SyncSender`
* `Receiver`
* `std::sync::mpsc`
* `channel`
* `sync_channel`
* `Iter`
* `Sender::send`
* `Sender::clone`
* `SyncSender::send`
* `SyncSender::try_send`
* `SyncSender::clone`
* `Receiver::recv`
* `Receiver::try_recv`
* `Receiver::iter`
* `SendError`
* `RecvError`
* `TrySendError::{mod, Full, Disconnected}`
* `TryRecvError::{mod, Empty, Disconnected}`
* `SendError::into_inner`
* `TrySendError::into_inner`

This is a breaking change due to the modification of where this module is
located, as well as the changing of the semantics of `send` and `recv`. Most
programs just need to rename imports of `std::comm` to `std::sync::mpsc` and
add calls to `unwrap` after a send or a receive operation.

[breaking-change]
@alexcrichton
Copy link
Member Author

I'm going to hold off the r+ until #20157 lands, but once it does I will r+ this.

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 2, 2015
Conflicts:
	src/doc/guide.md
	src/libcollections/bit.rs
	src/libcollections/btree/node.rs
	src/libcollections/slice.rs
	src/libcore/ops.rs
	src/libcore/prelude.rs
	src/librand/rand_impls.rs
	src/librustc/middle/check_match.rs
	src/librustc/middle/infer/region_inference/mod.rs
	src/librustc_driver/lib.rs
	src/librustdoc/test.rs
	src/libstd/bitflags.rs
	src/libstd/io/comm_adapters.rs
	src/libstd/io/mem.rs
	src/libstd/io/mod.rs
	src/libstd/io/net/pipe.rs
	src/libstd/io/net/tcp.rs
	src/libstd/io/net/udp.rs
	src/libstd/io/pipe.rs
	src/libstd/io/process.rs
	src/libstd/io/stdio.rs
	src/libstd/io/timer.rs
	src/libstd/io/util.rs
	src/libstd/macros.rs
	src/libstd/os.rs
	src/libstd/path/posix.rs
	src/libstd/path/windows.rs
	src/libstd/prelude/v1.rs
	src/libstd/rand/mod.rs
	src/libstd/rand/os.rs
	src/libstd/sync/barrier.rs
	src/libstd/sync/condvar.rs
	src/libstd/sync/future.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/mpsc/mpsc_queue.rs
	src/libstd/sync/mpsc/select.rs
	src/libstd/sync/mpsc/spsc_queue.rs
	src/libstd/sync/mutex.rs
	src/libstd/sync/once.rs
	src/libstd/sync/rwlock.rs
	src/libstd/sync/semaphore.rs
	src/libstd/sync/task_pool.rs
	src/libstd/sys/common/helper_thread.rs
	src/libstd/sys/unix/process.rs
	src/libstd/sys/unix/timer.rs
	src/libstd/sys/windows/c.rs
	src/libstd/sys/windows/timer.rs
	src/libstd/sys/windows/tty.rs
	src/libstd/thread.rs
	src/libstd/thread_local/mod.rs
	src/libstd/thread_local/scoped.rs
	src/libtest/lib.rs
	src/test/auxiliary/cci_capture_clause.rs
	src/test/bench/shootout-reverse-complement.rs
	src/test/bench/shootout-spectralnorm.rs
	src/test/compile-fail/array-old-syntax-2.rs
	src/test/compile-fail/bind-by-move-no-guards.rs
	src/test/compile-fail/builtin-superkinds-self-type.rs
	src/test/compile-fail/comm-not-freeze-receiver.rs
	src/test/compile-fail/comm-not-freeze.rs
	src/test/compile-fail/issue-12041.rs
	src/test/compile-fail/unsendable-class.rs
	src/test/run-pass/builtin-superkinds-capabilities-transitive.rs
	src/test/run-pass/builtin-superkinds-capabilities-xc.rs
	src/test/run-pass/builtin-superkinds-capabilities.rs
	src/test/run-pass/builtin-superkinds-self-type.rs
	src/test/run-pass/capturing-logging.rs
	src/test/run-pass/closure-bounds-can-capture-chan.rs
	src/test/run-pass/comm.rs
	src/test/run-pass/core-run-destroy.rs
	src/test/run-pass/drop-trait-enum.rs
	src/test/run-pass/hashmap-memory.rs
	src/test/run-pass/issue-13494.rs
	src/test/run-pass/issue-3609.rs
	src/test/run-pass/issue-4446.rs
	src/test/run-pass/issue-4448.rs
	src/test/run-pass/issue-8827.rs
	src/test/run-pass/issue-9396.rs
	src/test/run-pass/ivec-tag.rs
	src/test/run-pass/rust-log-filter.rs
	src/test/run-pass/send-resource.rs
	src/test/run-pass/send-type-inference.rs
	src/test/run-pass/sendable-class.rs
	src/test/run-pass/spawn-types.rs
	src/test/run-pass/task-comm-0.rs
	src/test/run-pass/task-comm-10.rs
	src/test/run-pass/task-comm-11.rs
	src/test/run-pass/task-comm-13.rs
	src/test/run-pass/task-comm-14.rs
	src/test/run-pass/task-comm-15.rs
	src/test/run-pass/task-comm-16.rs
	src/test/run-pass/task-comm-3.rs
	src/test/run-pass/task-comm-4.rs
	src/test/run-pass/task-comm-5.rs
	src/test/run-pass/task-comm-6.rs
	src/test/run-pass/task-comm-7.rs
	src/test/run-pass/task-comm-9.rs
	src/test/run-pass/task-comm-chan-nil.rs
	src/test/run-pass/task-spawn-move-and-copy.rs
	src/test/run-pass/task-stderr.rs
	src/test/run-pass/tcp-accept-stress.rs
	src/test/run-pass/tcp-connect-timeouts.rs
	src/test/run-pass/tempfile.rs
	src/test/run-pass/trait-bounds-in-arc.rs
	src/test/run-pass/trivial-message.rs
	src/test/run-pass/unique-send-2.rs
	src/test/run-pass/unique-send.rs
	src/test/run-pass/unwind-resource.rs
@bors bors merged commit bc83a00 into rust-lang:master Jan 2, 2015
@alexcrichton alexcrichton deleted the second-pass-comm branch January 3, 2015 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants