Lines Matching defs:sync
3 //! `once_cell` provides two new cell-like types, [`unsync::OnceCell`] and [`sync::OnceCell`]. A `OnceCell`
19 //! The `sync` flavor is thread-safe (that is, implements the [`Sync`] trait), while the `unsync` one is not.
22 //! [`sync::OnceCell`]: sync/struct.OnceCell.html
24 //! [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html
36 //! use once_cell::sync::OnceCell;
67 //! use std::{sync::Mutex, collections::HashMap};
69 //! use once_cell::sync::OnceCell;
82 //! There are also the [`sync::Lazy`] and [`unsync::Lazy`] convenience types to streamline this pattern:
85 //! use std::{sync::Mutex, collections::HashMap};
86 //! use once_cell::sync::Lazy;
103 //! [`sync::Lazy`]: sync/struct.Lazy.html
153 //! static RE: once_cell::sync::OnceCell<regex::Regex> = once_cell::sync::OnceCell::new();
170 //! use once_cell::sync::OnceCell;
209 //! use once_cell::sync::OnceCell;
263 //! |`sync::OnceCell<T>` | `&T` | assignable only once, may block the thread |
280 //! and [`lazy_cell`](https://github.com/indiv0/lazycell/) crates and [`std::sync::Once`]. In some sense,
283 //! To implement a sync flavor of `OnceCell`, this crates uses either a custom
284 //! re-implementation of `std::sync::Once` or `parking_lot::Mutex`. This is
291 //! [`std::sync::Once`]: https://doc.rust-lang.org/std/sync/struct.Once.html
306 //! **Should I use the sync or unsync flavor?**
309 //! `sync` is required. So, use `unsync` in single-threaded code and `sync` in multi-threaded. It's easy
389 // Similarly to a `Sync` bound on `sync::OnceCell`, we can use
828 pub mod sync {
850 /// use once_cell::sync::OnceCell;
941 /// use once_cell::sync::OnceCell;
943 /// let mut cell = std::sync::Arc::new(OnceCell::new());
945 /// let cell = std::sync::Arc::clone(&cell);
977 /// use once_cell::sync::OnceCell;
1008 /// use once_cell::sync::OnceCell;
1072 /// use once_cell::sync::OnceCell;
1106 /// use once_cell::sync::OnceCell;
1140 /// use once_cell::sync::OnceCell;
1156 /// use once_cell::sync::OnceCell;
1172 /// use once_cell::sync::OnceCell;
1196 /// use once_cell::sync::Lazy;
1266 /// use once_cell::sync::Lazy;
1286 /// use once_cell::sync::Lazy;
1302 /// use once_cell::sync::Lazy;
1319 /// use once_cell::sync::Lazy;
1358 /// share(&once_cell::sync::OnceCell::<S>::new());
1366 /// share(&once_cell::sync::Lazy::<S>::new(|| unimplemented!()));