|
1 |
| -use super::poison::once::ExclusiveState; |
2 | 1 | use crate::cell::UnsafeCell;
|
3 | 2 | use crate::mem::ManuallyDrop;
|
4 | 3 | use crate::ops::{Deref, DerefMut};
|
5 | 4 | use crate::panic::{RefUnwindSafe, UnwindSafe};
|
6 |
| -use crate::sync::Once; |
| 5 | +use crate::sync::nonpoison::once::Once; |
| 6 | +use crate::sys::sync::once::ExclusiveState; |
7 | 7 | use crate::{fmt, ptr};
|
8 | 8 |
|
9 |
| -// We use the state of a Once as discriminant value. Upon creation, the state is |
10 |
| -// "incomplete" and `f` contains the initialization closure. In the first call to |
11 |
| -// `call_once`, `f` is taken and run. If it succeeds, `value` is set and the state |
12 |
| -// is changed to "complete". If it panics, the Once is poisoned, so none of the |
13 |
| -// two fields is initialized. |
| 9 | +/// We use the state of a Once (the [`ExclusiveState`] enum) as discriminant value. |
| 10 | +/// |
| 11 | +/// Upon creation, the state is "incomplete" and `f` contains the initialization closure. In the |
| 12 | +/// first call to `call_once()`, `f` is taken and run. If it succeeds, `value` is set and the state |
| 13 | +/// is changed to "complete". If it panics, the [`Once`] is poisoned, so none of the two fields is |
| 14 | +/// initialized. |
| 15 | +/// |
| 16 | +/// [`call_once()`]: Once::call_once |
14 | 17 | union Data<T, F> {
|
15 | 18 | value: ManuallyDrop<T>,
|
16 | 19 | f: ManuallyDrop<F>,
|
@@ -63,7 +66,6 @@ union Data<T, F> {
|
63 | 66 | /// ```
|
64 | 67 | #[stable(feature = "lazy_cell", since = "1.80.0")]
|
65 | 68 | pub struct LazyLock<T, F = fn() -> T> {
|
66 |
| - // FIXME(nonpoison_once): if possible, switch to nonpoison version once it is available |
67 | 69 | once: Once,
|
68 | 70 | data: UnsafeCell<Data<T, F>>,
|
69 | 71 | }
|
|
0 commit comments