about summary refs log tree commit diff
path: root/src/libstd/sync
AgeCommit message (Collapse)AuthorLines
2018-09-29Fix Once perf regressionAleksey Kladov-0/+1
Because `call_once` is generic, but `is_completed` is not, we need `#[inline]` annotation to allow LLVM to inline `is_completed` into `call_once` in downstream crates.
2018-09-28Rewrite section on concurrencyGabriel Majeri-4/+5
2018-09-28Fix broken linksGabriel Majeri-5/+7
2018-09-27Address review commentsGabriel Majeri-14/+15
Reword the lead paragraph and turn the list items into complete sentences.
2018-09-27Make example code use global variablesGabriel Majeri-13/+14
Because `fn main()` was added automatically, the variables were actually local statics.
2018-09-27Expand the documentation for the std::sync moduleGabriel Majeri-4/+119
Provides an overview on why synchronization is required, as well a short summary of what sync primitives are available.
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.