about summary refs log tree commit diff
path: root/src/libstd/sync/mpsc/mod.rs
AgeCommit message (Collapse)AuthorLines
2017-05-20Auto merge of #42111 - ollie27:stab, r=Mark-Simulacrumbors-5/+5
Correct some stability versions These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-20Correct some stability versionsOliver Middleton-5/+5
These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-18fix typo in libstd/sync/mpsc/mod.rs docsDenis Andrejew-1/+1
2017-04-26Adding links and examples for various mspc pages #29377projektir-29/+254
2017-04-22Fix invalid linkageGuillaume Gomez-1/+1
2017-04-08Adding links around Sender/SyncSender/Receiver errors; Adding more ↵projektir-50/+84
documentation to channel() and sync_channel(); adding more links #29377
2017-04-03Fix styling issuesBryan Tan-6/+17
2017-03-31Fix warnings in examplesBryan Tan-9/+9
2017-03-31Fix broken links to std::iter::Iterator::nextBryan Tan-2/+2
2017-03-31Add links and examples to std::sync::mpsc docs (#29377)Bryan Tan-31/+136
This change adds links to to `Receiver`, `Iter`, `TryIter`, `IntoIter`, `Sender`, `SyncSender`, `SendError`, `RecvError`, `TryRecvError`, `RecvTimeoutError`, `TrySendError`, `Sender::send`, `SyncSender::send`, `SyncSender::try_send`, `Receiver::recv`, `Receiver::recv_timeout`, `Receiver::iter`, and `Receiver::try_iter`. Examples added to `Receiver`, `Sender`, `Receiver::iter`.
2017-03-30Add links to std::sync::mpsc docs #29377Bryan Tan-15/+25
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-6/+6
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2016-12-20Rollup merge of #38006 - frewsxcv:libstd-debug, r=alexcrichtonAlex Crichton-0/+3
Implement `fmt::Debug` for all structures in libstd. Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-19Rollup merge of #38421 - apasel422:issue-36934, r=alexcrichtonSeo Sanghyeon-107/+85
Replace invalid use of `&mut` with `UnsafeCell` in `std::sync::mpsc` Closes #36934 r? @alexcrichton
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-0/+3
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-16Replace invalid use of `&mut` with `UnsafeCell` in `std::sync::mpsc`Andrew Paseltiner-107/+85
Closes #36934
2016-12-15Stabilize std::sync::mpsc::Receiver::try_iterAaron Turon-3/+3
2016-12-07Improve and fix mpsc documentationCobrand-9/+20
Closes #37915 This commit enhances documentation with several links and fixes an error in the `sync_channel` documentation as well: `send` doesn't panic when the senders are all disconnected
2016-11-24Define `bound` argument in std::sync::mpsc::sync_channelfkjogu-5/+5
The `bound` argument in `std::sync::mpsc::sync:channel(bound: usize)` was not defined in the documentation.
2016-11-02Add Error implementation for std::sync::mpsc::RecvTimeoutError.Mark-Simulacrum-0/+32
2016-10-12Deprecate `Reflect`Nick Cameron-3/+2
[tracking issue](https://github.com/rust-lang/rust/issues/27749)
2016-10-05Restore `DISCONNECTED` state in `oneshot::Packet::send`Andrew Paseltiner-0/+7
Closes #32114
2016-09-30Ignore entire test modules on emscripten instead of individual testsBrian Anderson-54/+2
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+52
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-4/+0
2016-08-19std: Stabilize APIs for the 1.12 releaseAlex Crichton-4/+4
Stabilized * `Cell::as_ptr` * `RefCell::as_ptr` * `IpAddr::is_{unspecified,loopback,multicast}` * `Ipv6Addr::octets` * `LinkedList::contains` * `VecDeque::contains` * `ExitStatusExt::from_raw` - both on Unix and Windows * `Receiver::recv_timeout` * `RecvTimeoutError` * `BinaryHeap::peek_mut` * `PeekMut` * `iter::Product` * `iter::Sum` * `OccupiedEntry::remove_entry` * `VacantEntry::into_key` Deprecated * `Cell::as_unsafe_cell` * `RefCell::as_unsafe_cell` * `OccupiedEntry::remove_pair` Closes #27708 cc #27709 Closes #32313 Closes #32630 Closes #32713 Closes #34029 Closes #34392 Closes #34285 Closes #34529
2016-07-21Auto merge of #34724 - mitchmindtree:mpsc_receiver_try_recv, r=alexcrichtonbors-0/+56
Add a method to the mpsc::Receiver for producing a non-blocking iterator Currently, the `mpsc::Receiver` offers methods for receiving values in both blocking (`recv`) and non-blocking (`try_recv`) flavours. However only blocking iteration over values is supported. This PR adds a non-blocking iterator to complement the `try_recv` method, just as the blocking iterator complements the `recv` method. Use-case ------------- I predominantly use rust in my work on real-time systems and in particular real-time audio generation/processing. I use `mpsc::channel`s to communicate between threads in a purely non-blocking manner. I.e. I might send messages from the GUI thread to the audio thread to update the state of the dsp-graph, or from the audio thread to the GUI thread to display the RMS of each node. These are just a couple examples (I'm probably using 30+ channels across my various projects). I almost exclusively use the `mpsc::Receiver::try_recv` method to avoid blocking any of the real-time threads and causing unwanted glitching/stuttering. Now that I mention it, I can't think of a single time that I personally have used the `recv` method (though I can of course see why it would be useful, and perhaps the common case for many people). As a result of this experience, I can't help but feel there is a large hole in the `Receiver` API. | blocking | non-blocking | |------------|--------------------| | `recv` | `try_recv` | | `iter` | 🙀 | For the most part, I've been working around this using `while let Ok(v) = r.try_recv() { ... }`, however as nice as this is, it is clearly no match for the Iterator API. As an example, in the majority of my channel use cases I only want to check for *n* number of messages before breaking from the loop so that I don't miss the audio IO callback or hog the GUI thread for too long when an unexpectedly large number of messages are sent. Currently, I have to write something like this: ```rust let mut take = 100; while let Ok(msg) = rx.try_recv() { // Do stuff with msg if take == 0 { break; } take -= 1; } ``` or wrap the `try_recv` call in a `Range<usize>`/`FilterMap` iterator combo. On the other hand, this PR would allow for the following: ```rust for msg in rx.try_iter().take(100) { // Do stuff with msg } ``` I imagine this might also be useful to game devs, embedded or anyone doing message passing across real-time threads.
2016-07-21Fix issue in receiver_try_iter test where response sender would panic ↵mitchmindtree-3/+3
instead of break from the loop
2016-07-20Add the missing tracking issue field for #34931 to the receiver_try_iter ↵mitchmindtree-3/+3
stability attributes
2016-07-08Check for data in Receiver::try_recv before reporting disconnectAndrew-0/+9
2016-07-09Add the unstable attribute to the new mpsc::Receiver::try_iter APImitchmindtree-0/+3
2016-07-09Add a test for Receiver::try_itermitchmindtree-0/+28
2016-07-08add a non blocking iterator for the mpsc::Receivermitchmindtree-0/+25
Currently, the `mpsc::Receiver` offers methods for receiving values in both blocking (`recv`) and non-blocking (`try_recv`) flavours. However only blocking iteration over values is supported. This commit adds a non-blocking iterator to complement the `try_recv` method, just as the blocking iterator complements the `recv` method.
2016-06-22std: sync: Implement recv_timeout()Emilio Cobos Álvarez-13/+289
2016-05-09Utilize `Result::unwrap_err` in more places.Corey Farwell-1/+1
2016-03-01Explicitly opt out of `Sync` for `cell` and `mpsc` typesAndrew Paseltiner-0/+6
These types were already `!Sync`, but this improves error messages when they are used in contexts that require `Sync`, aligning them with conventions used with `Rc`, among others.
2016-02-23Register new snapshotsAaron Turon-2/+2
2016-02-18Remove unnecessary explicit lifetime bounds.Corey Farwell-2/+2
These explicit lifetimes can be ommitted because of lifetime elision rules. Instances were found using rust-clippy.
2016-01-20Auto merge of #30894 - antrik:debug-mpsc, r=brsonbors-0/+39
Minimal fix for https://github.com/rust-lang/rust/issues/30563 This covers all the public structs I think; except for Iter and IntoIter, which I don't know if or how they should be handled.
2016-01-14Require stability annotations on fields of tuple variantsVadim Petrochenkov-2/+2
2016-01-14std::sync::mpsc: Add fmt::Debug stubsOlaf Buddenhagen-0/+39
Minimal fix for https://github.com/rust-lang/rust/issues/30563 This covers all the public structs I think; except for Iter and IntoIter, which I don't know if or how they should be handled.
2015-11-18Add missing annotations and some testsVadim Petrochenkov-0/+6
2015-10-08typos: fix a grabbag of typos all over the placeCristi Cobzarenco-1/+1
2015-09-08some more clippy-based improvementsAndre Bogus-4/+4
2015-08-11Register new snapshotsAlex Crichton-3/+0
* Lots of core prelude imports removed * Makefile support for MSVC env vars and Rust crates removed * Makefile support for morestack removed
2015-08-03syntax: Implement #![no_core]Alex Crichton-0/+1
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-29std: Remove the curious inner moduleAlex Crichton-2/+2
This isn't actually necessary any more with the advent of `$crate` and changes in the compiler to expand macros to `::core::$foo` in the context of a `#![no_std]` crate. The libcore inner module was also trimmed down a bit to the bare bones.
2015-07-01Expand docs for recvSteve Klabnik-0/+42
Add an example, plus some text that covers the buffering nature of channels. Fixes #26497
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-10/+10
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-04-30Add downcasting to std::error::ErrorAaron Turon-3/+3
This commit brings the `Error` trait in line with the [Error interoperation RFC](https://github.com/rust-lang/rfcs/pull/201) by adding downcasting, which has long been intended. This change means that for any `Error` trait objects that are `'static`, you can downcast to concrete error types. To make this work, it is necessary for `Error` to inherit from `Reflect` (which is currently used to mark concrete types as "permitted for reflection, aka downcasting"). This is a breaking change: it means that impls like ```rust impl<T> Error for MyErrorType<T> { ... } ``` must change to something like ```rust impl<T: Reflect> Error for MyErrorType<T> { ... } ``` except that `Reflect` is currently unstable (and should remain so for the time being). For now, code can instead bound by `Any`: ```rust impl<T: Any> Error for MyErrorType<T> { ... } ``` which *is* stable and has `Reflect` as a super trait. The downside is that this imposes a `'static` constraint, but that only constrains *when* `Error` is implemented -- it does not actually constrain the types that can implement `Error`. [breaking-change]