Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish v1.12.0 #179

Merged
merged 1 commit into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Expand Up @@ -2,19 +2,23 @@

## Unreleased

-

## 1.12.0

- Add `OnceCell::wait`, a blocking variant of `get`.

## 1.11
## 1.11.0

- Add `OnceCell::with_value` to create initialized `OnceCell` in `const` context.
- Improve `Clone` implementation for `OnceCell`.
- Rewrite `parking_lot` version on top of `parking_lot_core`, for even smaller cells!

## 1.10
## 1.10.0

- upgrade `parking_lot` to `0.12.0` (note that this bumps MSRV with `parking_lot` feature enabled to `1.49.0`).

## 1.9
## 1.9.0

- Added an `atomic-polyfill` optional dependency to compile `race` on platforms without atomics

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "once_cell"
version = "1.12.0-pre.1"
version = "1.12.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand Down
21 changes: 20 additions & 1 deletion src/lib.rs
Expand Up @@ -875,7 +875,26 @@ pub mod sync {
}
}

/// Blocks until the value is set by another thread.
/// Gets the reference to the underlying value, blocking the current
/// thread until it is set.
///
/// ```
/// use once_cell::sync::OnceCell;
///
/// let mut cell = std::sync::Arc::new(OnceCell::new());
/// let t = std::thread::spawn({
/// let cell = std::sync::Arc::clone(&cell);
/// move || cell.set(92).unwrap()
/// });
///
/// // Returns immediately, but might return None.
/// let _value_or_none = cell.get();
///
/// // Will return 92, but might block until the other thread does `.set`.
/// let value: &u32 = cell.wait();
/// assert_eq!(*value, 92);
/// t.join().unwrap();;
/// ```
pub fn wait(&self) -> &T {
if !self.0.is_initialized() {
self.0.wait()
Expand Down