about summary refs log tree commit diff
path: root/src/libstd/sync
AgeCommit message (Collapse)AuthorLines
2017-02-21Add missing urls and examples into Barrier structsGuillaume Gomez-7/+69
2017-02-15Fix wording in LocalKey documentationStjepan Glavina-1/+1
2017-02-05Rollup merge of #39393 - ollie27:stab_impls, r=alexcrichtonCorey Farwell-7/+7
Fix a few impl stability attributes The versions show up in rustdoc.
2017-02-04tiny doc wording changeSon-1/+1
2017-01-29Fix a few impl stability attributesOliver Middleton-7/+7
The versions show up in rustdoc.
2017-01-10Add missing doc examples for MutexGuillaume Gomez-1/+79
2016-12-28Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]`Andrew Paseltiner-4/+2
CC #34761
2016-12-20Rollup merge of #38006 - frewsxcv:libstd-debug, r=alexcrichtonAlex Crichton-0/+64
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-328/+328
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/+64
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-328/+328
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-26Rollup merge of #38010 - frewsxcv:lock-creations, r=GuillaumeGomezSeo Sanghyeon-1/+22
Document how lock 'guard' structures are created.
2016-11-25Document how the `MutexGuard` structure is created.Corey Farwell-1/+8
Also, end sentence with a period.
2016-11-25Document how the `RwLockWriteGuard` structure is created.Corey Farwell-0/+7
2016-11-25Document how the `RwLockReadGuard` structure is created.Corey Farwell-0/+7
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-17Auto merge of #37162 - matklad:static-mut-lint, r=jseyfriedbors-7/+7
Lint against lowercase static mut Closes #37145. Lint for non mut statics was added in https://github.com/rust-lang/rust/pull/7523, and it explicitly did not cover mut statics. I am not sure why.
2016-10-14Rename static mut to upper caseAleksey Kladov-7/+7
2016-10-13UpdateNabeel Omer-3/+8
2016-10-13Updated RwLock DocsNabeel Omer-0/+3
2016-10-12Deprecate `Reflect`Nick Cameron-3/+2
[tracking issue](https://github.com/rust-lang/rust/issues/27749)
2016-10-05Auto merge of #36893 - apasel422:issue-32114, r=alexcrichtonbors-0/+9
Restore `DISCONNECTED` state in `oneshot::Packet::send` Closes #32114 I'm not sure if this is the best approach, but the current action of swapping `DISCONNECTED` with `DATA` seems wrong. Additionally, it is strange that the `send` method (and others in the `oneshot` module) takes `&mut self` despite performing atomic operations, as this requires extra discipline to avoid data races and lets us use methods like `AtomicUsize::get_mut` instead of methods that require a memory ordering.
2016-10-05Restore `DISCONNECTED` state in `oneshot::Packet::send`Andrew Paseltiner-0/+9
Closes #32114
2016-10-04Rollup merge of #36902 - ollie27:stab_impls, r=alexcrichtonManish Goregaokar-2/+0
std: Correct stability attributes for some implementations These are displayed by rustdoc so should be correct.
2016-10-02Add a platform-abstraction tidy scriptBrian Anderson-1/+1
This is intended to maintain existing standards of code organization in hopes that the standard library will continue to be refactored to isolate platform-specific bits, making porting easier; where "standard library" roughly means "all the dependencies of the std and test crates". This generally means placing restrictions on where `cfg(unix)`, `cfg(windows)`, `cfg(target_os)` and `cfg(target_env)` may appear, the basic objective being to isolate platform-specific code to the platform-specific `std::sys` modules, and to the allocation, unwinding, and libc crates. Following are the basic rules, though there are currently exceptions: - core may not have platform-specific code - liballoc_system may have platform-specific code - liballoc_jemalloc may have platform-specific code - libpanic_abort may have platform-specific code - libpanic_unwind may have platform-specific code - other crates in the std facade may not - std may have platform-specific code in the following places - sys/unix/ - sys/windows/ - os/ There are plenty of exceptions today though, noted in the whitelist.
2016-10-01std: Correct stability attributes for some implementationsOliver Middleton-2/+0
These are displayed by rustdoc so should be correct.
2016-09-30Ignore various entire test modules on emscriptenBrian Anderson-26/+5
2016-09-30Ignore entire test modules on emscripten instead of individual testsBrian Anderson-66/+3
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+89
2016-09-22Rollup merge of #36423 - GuillaumeGomez:eq_impl, r=pnkfelixJonathan Turner-1/+1
Add missing Eq implementations Part of #36301.
2016-09-18Add missing Eq implementationsGuillaume Gomez-1/+1
2016-09-14Rollup merge of #36396 - athulappadan:Default-docs, r=blussGuillaume Gomez-0/+3
Documentation of what Default does for each type Addresses #36265 I haven't changed the following types due to doubts: 1)src/libstd/ffi/c_str.rs 2)src/libcore/iter/sources.rs 3)src/libcore/hash/mod.rs 4)src/libcore/hash/mod.rs 5)src/librustc/middle/privacy.rs r? @steveklabnik
2016-09-11Use question_mark feature in libstd.Ahmed Charles-3/+2
2016-09-11Documentation of what does for each typeathulappadan-0/+3
2016-09-03Auto merge of #36104 - KiChjang:issue-35847, r=brsonbors-4/+24
Fix illegal instruction caused by overflow in channel cloning Fixes #35847. r? @alexcrichton
2016-08-30Auto merge of #35048 - tmiasko:monotonic-wait-timeout, r=alexcrichtonbors-1/+13
Use monotonic time in condition variables. Configure condition variables to use monotonic time using pthread_condattr_setclock on systems where this is possible. This fixes the issue when thread waiting on condition variable is woken up too late when system time is moved backwards.
2016-08-29Fix illegal instruction caused by overflow in channel cloningKeith Yeung-4/+24
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-31/+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-08-19Document that Condvar makes the best effort to use monotonic clock.Tomasz Miąsko-0/+8
2016-07-31Use monotonic time with condition variables.Tomasz Miąsko-1/+5
Configure condition variables to use monotonic time using pthread_condattr_setclock on systems where this is possible. This fixes the issue when thread waiting on condition variable is woken up too late when system time is moved backwards.
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-15Rollup merge of #34456 - tbu-:pr_ptr_null, r=aturonGuillaume Gomez-1/+2
Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`
2016-07-12std: Clean out deprecated APIsAlex Crichton-680/+170
This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-07-12Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`Tobias Bucher-1/+2