about summary refs log tree commit diff
path: root/library/std/src/sync
AgeCommit message (Collapse)AuthorLines
2020-09-25Rollup merge of #76932 - fusion-engineering-forks:condvar-promise, r=sfacklerJonas Schievink-11/+5
Relax promises about condition variable. For quite a while now, there have been plans to at some point use parking_lot or some other more efficient implementation of mutexes and condition variables. Right now, Mutex and CondVar both Box the 'real' mutex/condvar inside, to give it a stable address. This was done because implementations like pthread and Windows critical sections may not be moved. More efficient implementations based on futexes, WaitOnAddress, Windows SRW locks, parking_lot, etc. may be moved (while not borrowed), so wouldn't need boxing. However, not boxing them (which would be great goal to achieve), breaks a promise std currently makes about CondVar. CondVar promises to panic when used with different mutexes, to ensure consistent behaviour on all platforms. To this check, a mutex is considered 'the same' if the address of the 'real mutex' in the Box is the same. This address doesn't change when moving a `std::mutex::Mutex` object, effectively giving it an identity that survives moves of the Mutex object. If we ever switch to a non-boxed version, they no longer carry such an identity, and this check can no longer be made. Four options: 1. Always box mutexes. 2. Add a `MutexId` similar to `ThreadId`. Making mutexes bigger, and making it hard to ever have a `const fn new` for them. 3. Making the requirement of CondVar stricter: panic if the Mutex object itself moved. 4. Making the promise of CondVar weaker: don't promise to panic. 1, 2, and 3 seem like bad options. This PR updates the documentation for 4.
2020-09-25Rollup merge of #76978 - duckymirror:mpsc-from-doc, r=jyn514Jonas Schievink-0/+15
Documented From impls in std/sync/mpsc/mod.rs This is for #51430. r? @steveklabnik
2020-09-21Applied review commentsErik Hofmayer-0/+6
2020-09-21Rollup merge of #76936 - danielhenrymantilla:unsafecell_get_mut, r=RalfJungRalf Jung-6/+2
Add non-`unsafe` `.get_mut()` for `Unsafecell` - Tracking issue: https://github.com/rust-lang/rust/issues/76943 As discussed in: https://internals.rust-lang.org/t/add-non-unsafe-get-mut-for-unsafecell/12407 - ### [Rendered documentation](https://modest-dubinsky-1f9f47.netlify.app/core/cell/struct.unsafecell) This PR tries to move the sound `&mut UnsafeCell<T> -> &mut T` projection that all the "downstream" constructions were already relying on, up to the root abstraction, where it rightfully belongs, and officially blessing it. - this **helps reduce the amount of `unsafe` snippets out there** (_c.f._, the second commit of this PR: https://github.com/rust-lang/rust/pull/76936/commits/09503fd1b30c83ca605546fa3f899721e41e68c6) The fact that this getter is now expose for `UnsafeCell<T>` itself, will also help convey the idea that **`UnsafeCell` is not magical _w.r.t._ `&mut` accesses**, contrary to what some people incorrectly think. - Even the standard library itself at some point had such a confusion, _c.f._ this comment where there is a mention of multi-threaded (and thus _shared_) access despite dealing with exclusive references over unique ownership: https://github.com/rust-lang/rust/blob/59fb88d061544a035f3043b47594b34789204cee/library/core/src/cell.rs#L498-L499 r? @RalfJung
2020-09-20Fix nitsAlexis Bourget-4/+3
2020-09-20Replace unneeded `unsafe` calls to `.get()` with calls to `.get_mut()`Daniel Henry-Mantilla-6/+2
2020-09-20Documented From impls in std/sync/mpsc/mod.rsErik Hofmayer-0/+9
2020-09-19Relax promises about condition variable.Mara Bos-11/+5
This allows for futex or thread parking based implementations in the future.
2020-09-18Fix broken linkAlexis Bourget-3/+3
2020-09-18Finish moving to intra doc links for std::syncAlexis Bourget-51/+34
2020-09-12Mark Once::new as #[inline].Mara Bos-0/+1
Without this, it was not inlined in SyncOnceCell::into_inner(), causing unecessary checks and dead code.
2020-09-06Auto merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAusbors-17/+17
Use Arc::clone and Rc::clone in documentation This PR replaces uses of `x.clone()` by `Rc::clone(&x)` (or `Arc::clone(&x)`) to better match the documentation for those types. @rustbot modify labels: T-doc
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-2384/+2375
Also doing fmt inplace as requested.
2020-08-30Move to Arc::clone(&x) over x.clone() in library/stdAlexis Bourget-17/+17
2020-08-23Prefer https link for wikipedia URLsLzu Tao-1/+1
2020-08-22Use intra-doc-links in `std::sync::*`LeSeulArtichaut-136/+53
2020-08-02fix typosliuzhenyu-1/+1
2020-07-27mv std libs to library/mark-0/+8854