about summary refs log tree commit diff
path: root/src/libstd/sync
AgeCommit message (Collapse)AuthorLines
2018-09-06Fix invalid urlsGuillaume Gomez-4/+0
2018-09-05Auto merge of #53075 - Mark-Simulacrum:update-cargolock, r=alexcrichtonbors-1/+1
Update Cargo.lock This also includes major version bumps for the rand crate used by core, std, and alloc tests, among other crates (regex, etc.) used elsewhere. Since these are all internal there should be no user-visible changes. r? @alexcrichton
2018-09-05Auto merge of #53027 - matklad:once_is_completed, r=alexcrichtonbors-14/+59
Allow to check if sync::Once is already initialized Hi! I propose to expose a way to check if a `Once` instance is initialized. I need it in `once_cell`. `OnceCell` is effetively a pair of `(Once, UnsafeCell<Option<T>>)`, which can set the `T` only once. Because I can't check if `Once` is initialized, I am forced to add an indirection and check the value of ptr instead: https://github.com/matklad/once_cell/blob/8127a81976c3f2f4c0860562c3f14647ebc025c0/src/lib.rs#L423-L429 https://github.com/matklad/once_cell/blob/8127a81976c3f2f4c0860562c3f14647ebc025c0/src/lib.rs#L457-L461 The `parking_lot`'s version of `Once` exposes the state as an enum: https://docs.rs/parking_lot/0.6.3/parking_lot/struct.Once.html#method.state. I suggest, for now, just to add a simple `bool` function: this fits my use-case perfectly, exposes less implementation details, and is forward-compatible with more fine-grained state checking.
2018-09-04Breaking change upgradesMark Rousskov-1/+1
2018-08-19Fix typos found by codespell.Matthias Krüger-1/+1
2018-08-14Auto merge of #52936 - felixrabe:patch-1, r=alexcrichtonbors-0/+28
Document #39364 – Panic in mpsc::Receiver::recv_timeout I can still reproduce #39364 with the example code at https://github.com/rust-lang/rust/issues/39364#issuecomment-320637702. I'm opening this PR in an attempt to document this bug as a known issue in [libstd/sync/mpsc/mod.rs](https://github.com/rust-lang/rust/blob/master/src/libstd/sync/mpsc/mod.rs). Inputs very much welcome. ([Nightly docs for `recv_timeout`.](https://doc.rust-lang.org/nightly/std/sync/mpsc/struct.Receiver.html?search=#method.recv_timeout))
2018-08-09Reduce code duplication in OnceAleksey Kladov-14/+18
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-06Remove references to `StaticMutex` which got removed a while agoRalf Jung-6/+4
2018-08-03Fix trailnig WSAleksey Kladov-1/+1
2018-08-03Allow to check if sync::Once is initializedAleksey Kladov-0/+41
2018-08-03Specify reentrancy gurantees of `Once::call_once`Aleksey Kladov-0/+4
2018-08-01Document #39364 (WIP)Felix Rabe-0/+6
2018-07-25Merge remote-tracking branches 'ljedrz/dyn_libcore', 'ljedrz/dyn_libstd' and ↵Tatsuyuki Ishi-7/+7
'ljedrz/dyn_libterm' into dyn-rollup
2018-07-17sync::Once: Use Acquire on the hot path, and explain why we don't use it ↵Ralf Jung-2/+10
elsewhere
2018-07-11Uncapitalize "If"Matt Kraai-1/+1
2018-07-10remove sync::Once::call_once 'staticChristopher Durham-6/+6
- [std: Rewrite the `sync` modulehttps://github.com/rust-lang/rust/commit/71d4e77db8ad4b6d821da7e5d5300134ac95974e) (Nov 2014) ```diff - pub fn doit(&self, f: ||) { + pub fn doit(&'static self, f: ||) { ``` > ```text > The second layer is the layer provided by `std::sync` which is intended to be > the thinnest possible layer on top of `sys_common` which is entirely safe to > use. There are a few concerns which need to be addressed when making these > system primitives safe: > > * Once used, the OS primitives can never be **moved**. This means that they > essentially need to have a stable address. The static primitives use > `&'static self` to enforce this, and the non-static primitives all use a > `Box` to provide this guarantee. > ``` The author of this diff is @alexcrichton. `sync::Once` contains only a pointer to (privately hidden) `Waiter`s, which are all stack-allocated. The `'static` bound to `sync::Once` is thus unnecessary to guarantee that any OS primitives are non-relocatable. See https://internals.rust-lang.org/t/sync-once-per-instance/7918 for more context.
2018-07-10Deny bare trait objects in `src/libstd`.ljedrz-7/+7
2018-06-29Rename alloc::arc to alloc::sync, to match std::syncSimon Sapin-1/+1
2018-06-17libstd: add an RAII utility for sys_common::mutex::MutexNODA, Kai-2/+2
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2018-05-24Update the `Once` docs to use `Once::new`Tobias Bucher-10/+10
2018-05-24Add `Once::new` as a way of constructing a `Once`Tobias Bucher-1/+2
2018-05-07Add explanation for #[must_use] on mutex guardsManish Goregaokar-3/+3
2018-04-28stabilize `#[must_use]` for functions and must-use operatorsZack M. Davis-0/+2
This is in the matter of RFC 1940 and tracking issue #43302.
2018-04-12Import the `alloc` crate as `alloc_crate` in stdSimon Sapin-4/+3
… to make the name `alloc` available.
2018-02-25Rollup merge of #47970 - vlovich:condvar_wait_until, r=dtolnaykennytm-2/+214
Add Condvar APIs not susceptible to spurious wake Provide wait_until and wait_timeout_until helper wrappers that aren't susceptible to spurious wake. Additionally wait_timeout_until makes it possible to more easily write code that waits for a fixed amount of time in face of spurious wakes since otherwise each user would have to do math on adjusting the duration. Implements #47960.
2018-02-20Fix doc compile errorVitali Lovich-1/+1
2018-02-18Rollup merge of #48275 - matthiaskrgr:codespell, r=kennytm,varkorGuillaume Gomez-2/+2
fix more typos found by codespell.
2018-02-17Fix tidy violationVitali Lovich-3/+5
2018-02-17fix more typos found by codespell.Matthias Krüger-2/+2
2018-02-16Fix unit test compilationVitali Lovich-11/+17
Also fix some code snippets in documentation.
2018-02-15Fix condvar exampleGuillaume Gomez-2/+4
2018-02-13Misc fixesVitali Lovich-4/+4
Switch feature guards to unstable Add missing semicolon Remove mut that's no longer necessary
2018-02-12Fix wait_timeout valueVitali Lovich-1/+1
2018-02-05Simplify wait_timeout_until & fix condition typoVitali Lovich-8/+7
2018-02-02Review responseVitali Lovich-8/+10
Make condition closure accept mut T&. Clarify spurious wakeup documentation. Cleanup doc example code.
2018-02-02Fix typoVitali Lovich-1/+1
2018-02-02Add Condvar APIs not susceptible to spurious wakeVitali Lovich-2/+205
Provide wait_until and wait_timeout_until helper wrappers that aren't susceptible to spurious wake.
2018-01-10fix typo rwlock.rsBulat Musin-1/+1
Hi. Fixed typo: contained -> content
2017-12-27Correct a few stability attributesOliver Middleton-2/+2
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 #46287 - SimonSapin:stable-constness, r=aturonkennytm-1/+0
Stabilize const-calling existing const-fns in std Fixes #46038
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-28Rollup merge of #45506 - ia0:mpsc_recv_error_from, r=alexcrichtonkennytm-0/+27
Implement From<RecvError> for TryRecvError and RecvTimeoutError According to the documentation, it looks to me that `TryRecvError` and `RecvTimeoutError` are strict extensions of `RecvError`. As such, it makes sense to allow conversion from the latter type to the two former types without constraining future developments. This permits to write `input.recv()?` and `input.recv_timeout(timeout)?` in the same function for example.