1
Fork 0

std: Second pass stabilization for comm

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]
This commit is contained in:
Alex Crichton 2014-12-23 11:53:35 -08:00
parent bb8f4fc3b7
commit bc83a009f6
109 changed files with 1175 additions and 1206 deletions

View file

@ -449,7 +449,6 @@ static dot_dot_static: &'static [u8] = b"..";
mod tests {
use prelude::v1::*;
use str;
use super::*;
macro_rules! t {
(s: $path:expr, $exp:expr) => (

View file

@ -1119,10 +1119,13 @@ fn prefix_len(p: Option<PathPrefix>) -> uint {
#[cfg(test)]
mod tests {
use prelude::v1::*;
use super::*;
use prelude::v1::Option::{mod, Some, None};
use prelude::v1::{Vec, Clone, AsSlice, SliceExt, CloneSliceExt, IteratorExt};
use prelude::v1::{DoubleEndedIteratorExt, Str, ToString, GenericPath};
use super::PathPrefix::*;
use super::parse_prefix;
use super::*;
macro_rules! t {
(s: $path:expr, $exp:expr) => (