about summary refs log tree commit diff
path: root/src/libstd/sync/mpsc/mod.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-3033/+0
2020-07-16Rollup merge of #73269 - mzohreva:mz/sgx-wait-timeout, r=jethrogbManish Goregaokar-9/+0
Enable some timeouts in SGX platform This would partially resolve https://github.com/fortanix/rust-sgx/issues/31 cc @jethrogb and @Goirad
2020-06-12Enable some timeouts in SGX platformMohsen Zohrevandi-9/+0
This would partially resolve https://github.com/fortanix/rust-sgx/issues/31
2020-06-10Migrate to numeric associated constsLzu Tao-2/+1
2019-12-28Rollup merge of #67632 - kraai:remove-collapsed-reference-links, r=steveklabnikOliver Scherer-4/+4
Convert collapsed to shortcut reference links
2019-12-26Convert collapsed to shortcut reference linksMatthew Kraai-4/+4
2019-12-26Remove redundant link textsMatthew Kraai-1/+1
2019-12-24Deprecate Error::description for realDavid Tolnay-0/+5
`description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This commit: - adds #[rustc_deprecated(since = "1.41.0")] to Error::description; - moves description (and cause, which is also deprecated) below the source and backtrace methods in the Error trait; - reduces documentation of description and cause to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call description; - removes the description function of all *currently unstable* Error impls in the standard library; - marks #[allow(deprecated)] the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of description in example code and the compiler.
2019-11-29Format libstd with rustfmtDavid Tolnay-259/+251
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-10-13Remove Error::cause impls equal to deafult implLinus Färnstrand-20/+0
2019-05-17Remove the unstable and deprecated mpsc_selectJosh Stone-83/+2
This removes macro `select!` and `std::sync::mpsc::{Handle, Select}`, which were all unstable and have been deprecated since 1.32.
2019-04-25ignore-tidy-filelength on all files with greater than 3000 linesvarkor-0/+2
2019-04-08Add must_use annotations to Result::is_ok and is_errAlex Gaynor-1/+1
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-12/+12
2019-03-25SGX target: fix std unit testsJethro Beekman-7/+16
2019-02-28libstd => 2018Taiki Endo-12/+12
2019-02-12Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnikbors-1/+1
Cosmetic improvements to doc comments This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase). r? @steveklabnik Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-11Move out tests of a deprecated module to work around `#[test]` bugsOliver Scherer-0/+3
https://github.com/rust-lang/rust/issues/47238
2019-02-10tests: doc commentsAlexander Regueiro-1/+1
2019-01-02Auto merge of #56827 - faern:eliminate-recv-timeout-panic, r=KodrAusbors-6/+18
Eliminate Receiver::recv_timeout panic Fixes #54552. This panic is because `recv_timeout` uses `Instant::now() + timeout` internally. This possible panic is not mentioned in the documentation for this method. Very recently we merged (still unstable) support for checked addition (#56490) of `Instant + Duration`, so it's now finally possible to add these together without risking a panic.
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-14Use checked_add for adding time in recv_timeoutLinus Färnstrand-6/+18
2018-11-08Deprecate channel selectionStjepan Glavina-0/+1
2018-11-06refactor: use shorthand fieldsteresy-1/+1
2018-08-07"Panics" -> "Known Issues"; rm trailing WSFelix Rabe-2/+2
2018-08-07Less words better than moar wordsFelix Rabe-2/+2
2018-08-07RephraseFelix Rabe-2/+2
2018-08-07Document panic in mpsc::Receiver::recv_timeoutFelix Rabe-1/+23
2018-08-01Document #39364 (WIP)Felix Rabe-0/+6
2018-07-25Merge remote-tracking branches 'ljedrz/dyn_libcore', 'ljedrz/dyn_libstd' and ↵Tatsuyuki Ishi-5/+5
'ljedrz/dyn_libterm' into dyn-rollup
2018-07-11Uncapitalize "If"Matt Kraai-1/+1
2018-07-10Deny bare trait objects in `src/libstd`.ljedrz-5/+5
2017-11-29Rollup merge of #46323 - ia0:fix_mpsc_error_conv, r=kennytmkennytm-3/+3
Fix since for mpsc_error_conversions This is a followup of #45506.
2017-11-29Rollup merge of #45969 - ia0:mpsc_recv_deadline, r=alexcrichtonkennytm-2/+63
Add std::sync::mpsc::Receiver::recv_deadline() Essentially renames recv_max_until to recv_deadline (mostly copying recv_timeout documentation). This function is useful to avoid the often unnecessary call to Instant::now in recv_timeout (e.g. when the user already has a deadline). A concrete example would be something along those lines: ```rust use std::sync::mpsc::Receiver; use std::time::{Duration, Instant}; /// Reads a batch of elements /// /// Returns as soon as `max_size` elements have been received or `timeout` expires. fn recv_batch_timeout<T>(receiver: &Receiver<T>, timeout: Duration, max_size: usize) -> Vec<T> { recv_batch_deadline(receiver, Instant::now() + timeout, max_size) } /// Reads a batch of elements /// /// Returns as soon as `max_size` elements have been received or `deadline` is reached. fn recv_batch_deadline<T>(receiver: &Receiver<T>, deadline: Instant, max_size: usize) -> Vec<T> { let mut result = Vec::new(); while let Ok(x) = receiver.recv_deadline(deadline) { result.push(x); if result.len() == max_size { break; } } result } ```
2017-11-28Fix doc test of previous commitJulien Cretin-0/+2
2017-11-28Fix since for mpsc_error_conversionsJulien Cretin-3/+3
2017-11-27Use an unstable feature linked to #46316Julien Cretin-1/+1
2017-11-13Add std::sync::mpsc::Receiver::recv_deadline()Julien Cretin-2/+61
Essentially renames recv_max_until to recv_deadline (mostly copying recv_timeout documentation). This function is useful to avoid the often unnecessary call to Instant::now in recv_timeout (e.g. when the user already has a deadline). A concrete example would be something along those lines: ```rust use std::sync::mpsc::Receiver; use std::time::{Duration, Instant}; /// Reads a batch of elements /// /// Returns as soon as `max_size` elements have been received or `timeout` expires. fn recv_batch_timeout<T>(receiver: &Receiver<T>, timeout: Duration, max_size: usize) -> Vec<T> { recv_batch_deadline(receiver, Instant::now() + timeout, max_size) } /// Reads a batch of elements /// /// Returns as soon as `max_size` elements have been received or `deadline` is reached. fn recv_batch_deadline<T>(receiver: &Receiver<T>, deadline: Instant, max_size: usize) -> Vec<T> { let mut result = Vec::new(); while let Ok(x) = receiver.recv_deadline(deadline) { result.push(x); if result.len() == max_size { break; } } result } ```
2017-10-31Implement From<SendError<T>> for TrySendError<T>Julien Cretin-2/+11
2017-10-25Implement From<RecvError> for TryRecvError and RecvTimeoutErrorJulien Cretin-0/+18
2017-10-11Auto merge of #44963 - JLockerman:fix_spsc, r=alexcrichtonbors-0/+2
Improve performance of spsc_queue and stream. This PR makes two main changes: 1. It switches the `spsc_queue` node caching strategy from keeping a shared counter of the number of nodes in the cache to keeping a consumer only counter of the number of node eligible to be cached. 2. It separates the consumer and producers fields of `spsc_queue` and `stream` into a producer cache line and consumer cache line. Overall, it speeds up `mpsc` in `spsc` mode by 2-10x. Variance is higher than I'd like (that 2-10x speedup is on one benchmark), I believe this is due to the drop check in `send` (`fn stream::Queue::send:107`). I think this check can be combined with the sleep detection code into a version which only uses 1 shared variable, and only one atomic access per `send`, but I haven't looked through the select implementation enough to be sure. The code currently assumes a cache line size of 64 bytes. I added a CacheAligned newtype in `mpsc` which I expect to reuse for `shared`. It doesn't really belong there, it would probably be best put in `core::sync::atomic`, but putting it in `core` would involve making it public, which I thought would require an RFC. Benchmark runner is [here](https://github.com/JLockerman/queues/tree/3eca46279c53eb75833c5ecd416de2ac220bd022/shootout), benchmarks [here](https://github.com/JLockerman/queues/blob/3eca46279c53eb75833c5ecd416de2ac220bd022/queue_bench/src/lib.rs#L170-L293). Fixes #44512.
2017-10-09Refactor to use `debug_struct` in several Debug implsMalo Jaffré-21/+3
Fixes #44771.
2017-10-01Improve performance of spsc_queue and stream.Joshua Lockerman-0/+2
This commit makes two main changes. 1. It switches the spsc_queue node caching strategy from keeping a shared counter of the number of nodes in the cache to keeping a consumer only counter of the number of node eligible to be cached. 2. It separate the consumer and producers fields of spsc_queue and stream into a producer cache line and consumer cache line.
2017-06-21Rollup merge of #42397 - sfackler:syncsender-sync, r=alexcrichtonCorey Farwell-5/+0
Implement Sync for SyncSender r? @alexcrichton
2017-06-02Implement Sync for SyncSenderSteven Fackler-5/+0
2017-06-02Rewrite `Receiver::try_iter` doc example to show resulting values.Corey Farwell-8/+13
2017-06-02Rewrite `Receiver::iter` doc example to show resulting values.Corey Farwell-6/+8
2017-06-01Auto merge of #42281 - eddyb:well-adjusted, r=nikomatsakisbors-10/+10
Decompose Adjustment into smaller steps and remove the method map. The method map held method callee information for: * actual method calls (`x.f(...)`) * overloaded unary, binary, indexing and call operators * *every overloaded deref adjustment* (many can exist for each expression) That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with: * a desire to compose adjustments more freely * containing the autoderef logic better to avoid mutation within an inference snapshot * not creating `TyFnDef` types which are incompatible with the original one * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs` * to fix #3548 by explicitly writing autorefs for the RHS of comparison operators Individual commits tell their own story, of "atomic" changes avoiding breaking semantics. Future work based on this PR could include: * removing the signature from `TyFnDef`, now that it's always "canonical" * some questions of variance remain, as subtyping *still* treats the signature differently * moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits` * allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments * transitive coercions (e.g. reify or unsize after multiple steps of autoderef) r? @nikomatsakis
2017-06-01tests: fix fallout from empowering unused_allocation in comparisons.Eduard-Mihai Burtescu-10/+10
2017-05-31Rewrite doc examples for `Receiver::recv_timeout`.Corey Farwell-4/+33