about summary refs log tree commit diff
path: root/library/std/src/sync/mod.rs
AgeCommit message (Collapse)AuthorLines
2025-08-23move `WaitTimeoutResult` up to `mod.rs`Connor Tsui-1/+64
Since `WaitTimeoutResult` is poison-agnostic, we want to use the same type for both variants of `Condvar`. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-07-29add `nonpoison::mutex` implementationConnor Tsui-0/+2
Adds the equivalent `nonpoison` types to the `poison::mutex` module. These types and implementations are gated under the `nonpoison_mutex` feature gate. Also blesses the ui tests that now have a name conflicts (because these types no longer have unique names). The full path distinguishes the different types. Co-authored-by: Aandreba <aandreba@gmail.com> Co-authored-by: Trevor Gross <tmgross@umich.edu>
2025-03-22Implement `UniqueArc`Frank King-0/+2
2025-01-02Move some things to `std::sync::poison` and reexport them in `std::sync`Pavel Grigorenko-19/+37
2024-09-30Add multi-producer, multi-consumer channel (mpmc)Obei Sideg-1/+8
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-09-13Update tests for hidden references to mutable staticObei Sideg-0/+3
2024-07-29Reformat `use` declarations.Nicholas Nethercote-10/+9
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-15std: suggest OnceLock over OnceJubilee Young-1/+2
2024-06-11replace version placeholderPietro Albini-1/+1
2024-06-02Differ LazyLock vs. OnceLock in std::sync overviewJubilee Young-1/+4
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-1/+1
2024-02-29Rollup merge of #110543 - joboet:reentrant_lock, r=m-ou-seMatthias Krüger-2/+3
Make `ReentrantLock` public Implements the ACP rust-lang/libs-team#193. ``@rustbot`` label +T-libs-api +S-waiting-on-ACP
2024-02-23std: make `ReentrantLock` publicjoboet-2/+3
2023-12-05Fix Condvar typo, add public re-exports of Mapped*Guard.Zachary S-0/+4
2023-04-28replace version placeholdersPietro Albini-1/+1
2023-03-29Documentation updates to better share the purpose of OnceCell/OnceLockTrevor Gross-1/+4
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-2/+2
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-01-26std: optimize `LazyLock` sizejoboet-1/+1
2022-11-14std: move `ReentrantMutex` to `sync`joboet-0/+3
2022-11-09initial port of crossbeam-channelIbraheem Ahmed-0/+1
2022-06-30Rollup merge of #97629 - guswynn:exclusive_struct, r=m-ou-seMatthias Krüger-0/+2
[core] add `Exclusive` to sync (discussed here: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Adding.20.60SyncWrapper.60.20to.20std) `Exclusive` is a wrapper that exclusively allows mutable access to the inner value if you have exclusive access to the wrapper. It acts like a compile time mutex, and hold an unconditional `Sync` implementation. ## Justification for inclusion into std - This wrapper unblocks actual problems: - The example that I hit was a vector of `futures::future::BoxFuture`'s causing a central struct in a script to be non-`Sync`. To work around it, you either write really difficult code, or wrap the futures in a needless mutex. - Easy to maintain: this struct is as simple as a wrapper can get, and its `Sync` implementation has very clear reasoning - Fills a gap: `&/&mut` are to `RwLock` as `Exclusive` is to `Mutex` ## Public Api ```rust // core::sync #[derive(Default)] struct Exclusive<T: ?Sized> { ... } impl<T: ?Sized> Sync for Exclusive {} impl<T> Exclusive<T> { pub const fn new(t: T) -> Self; pub const fn into_inner(self) -> T; } impl<T: ?Sized> Exclusive<T> { pub const fn get_mut(&mut self) -> &mut T; pub const fn get_pin_mut(Pin<&mut self>) -> Pin<&mut T>; pub const fn from_mut(&mut T) -> &mut Exclusive<T>; pub const fn from_pin_mut(Pin<&mut T>) -> Pin<&mut Exclusive<T>>; } impl<T: Future> Future for Exclusive { ... } impl<T> From<T> for Exclusive<T> { ... } impl<T: ?Sized> Debug for Exclusive { ... } ``` ## Naming This is a big bikeshed, but I felt that `Exclusive` captured its general purpose quite well. ## Stability and location As this is so simple, it can be in `core`. I feel that it can be stabilized quite soon after it is merged, if the libs teams feels its reasonable to add. Also, I don't really know how unstable feature work in std/core's codebases, so I might need help fixing them ## Tips for review The docs probably are the thing that needs to be reviewed! I tried my best, but I'm sure people have more experience than me writing docs for `Core` ### Implementation: The API is mostly pulled from https://docs.rs/sync_wrapper/latest/sync_wrapper/struct.SyncWrapper.html (which is apache 2.0 licenesed), and the implementation is trivial: - its an unsafe justification for pinning - its an unsafe justification for the `Sync` impl (mostly reasoned about by ````@danielhenrymantilla```` here: https://github.com/Actyx/sync_wrapper/pull/2) - and forwarding impls, starting with derivable ones and `Future`
2022-06-23add tracking issue for exclusiveGus Wynn-1/+1
2022-06-16Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock`Maybe Waffle-0/+7
2022-06-07[core] add Exclusive to syncGus Wynn-0/+2
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-1/+1
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2021-04-22Move `sys_common::poison` to `sync::poison`Christiaan Dirkx-2/+3
2020-07-27mv std libs to library/mark-0/+179