#[repr(transparent)]pub struct AtomicDataWithOwner<V, Own> {
pub data: V,
pub permission: Tracked<Own>,
}Expand description
A structure that combines some data with a permission to access it.
For example, in aster_common we can see a lot of structs with
its owner associated. E.g., MetaSlotOwner is the owner of
MetaSlot. This struct can be used to represent such a combination
because now the permission is no longer exclusively owner by some
specific CPU and is “shared” among multiple threads via atomic
operations.
This struct is especially useful when used in conjunction with
synchronization primitives like [Once], where we want to ensure that
the data is initialized only once and the permission is preserved
throughout the lifetime of the data.
§Examples
ⓘ
struct MyData {
pub foo: u32,
pub bar: u32,
}
tracked struct MyDataWithOwner {
pub baz: nat,
pub quz: Seq<int>,
}
impl Inv for MyData {
// inv...
}
impl Predicate<MyData> for MyDataWithOwner {
#[verifier::inline]
open spec fn inv_with(self, v: MyData) -> bool {
&&& self.baz == v.foo as nat
&&& self.quz.len() == v.bar as nat
}
}
type Data = AtomicDataWithOwner<MyData, MyDataWithOwner>;Fields§
§data: VThe underlying data.
permission: Tracked<Own>The permission to access the data.
Implementations§
Source§impl<V, Own> AtomicDataWithOwner<V, Own>
impl<V, Own> AtomicDataWithOwner<V, Own>
Trait Implementations§
Source§impl<V, Own> Deref for AtomicDataWithOwner<V, Own>
impl<V, Own> Deref for AtomicDataWithOwner<V, Own>
Source§impl<V, Own: Predicate<V>> Inv for AtomicDataWithOwner<V, Own>
impl<V, Own: Predicate<V>> Inv for AtomicDataWithOwner<V, Own>
Source§impl<T, Own> View for AtomicDataWithOwner<T, Own>
impl<T, Own> View for AtomicDataWithOwner<T, Own>
impl<V, Own> !Clone for AtomicDataWithOwner<V, Own>
impl<V, Own> !Copy for AtomicDataWithOwner<V, Own>
Auto Trait Implementations§
impl<V, Own> Freeze for AtomicDataWithOwner<V, Own>where
V: Freeze,
impl<V, Own> RefUnwindSafe for AtomicDataWithOwner<V, Own>where
V: RefUnwindSafe,
Own: RefUnwindSafe,
impl<V, Own> Send for AtomicDataWithOwner<V, Own>
impl<V, Own> Sync for AtomicDataWithOwner<V, Own>
impl<V, Own> Unpin for AtomicDataWithOwner<V, Own>
impl<V, Own> UnsafeUnpin for AtomicDataWithOwner<V, Own>where
V: UnsafeUnpin,
impl<V, Own> UnwindSafe for AtomicDataWithOwner<V, Own>where
V: UnwindSafe,
Own: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more