pub struct SpinLockGuard<'a, T, G: SpinGuardian, I: ResourceInvariant<T> = TrivialResourceInvariant> { /* private fields */ }Expand description
A guard that provides exclusive access to the data protected by a SpinLock.
§Verified Properties
§Verification Design
The guard is extended with tracked fields holding both the ghost permission
(PointsTo<T>)
and the user-supplied tracked resource. The permission grants exclusive ownership of the
protected data and enables verified access to the PCell<T>.
§Invariant
The guard maintains a type invariant ensuring that its ghost permission’s ID matches the lock’s internal cell ID. This guarantees that the permission corresponds to the correct protected data.
#[verifier::type_invariant]
spec fn type_inv(self) -> bool{
self.lock.cell_id() == self.tracked_perm@.id()
}Note: The invariant is encapsulated using the #[verifier::type_invariant] mechanism.
It internally holds at all steps during the method executions and is NOT exposed in the public APIs’ pre- and post-conditions.
Implementations§
Source§impl<'a, T, G: SpinGuardian, I: ResourceInvariant<T>> SpinLockGuard<'a, T, G, I>
impl<'a, T, G: SpinGuardian, I: ResourceInvariant<T>> SpinLockGuard<'a, T, G, I>
Sourcepub closed spec fn resource(self) -> I::Resource
pub closed spec fn resource(self) -> I::Resource
The tracked resource associated with the protected value.
Sourcepub closed spec fn constant(self) -> I::Constant
pub closed spec fn constant(self) -> I::Constant
The immutable user constant associated with the guarded spin lock.
Sourcepub open spec fn view(self) -> T
pub open spec fn view(self) -> T
{ self.value() }The value stored in the lock. It is an alias of Self::value.
Sourcepub proof fn tracked_borrow_mut_resource(tracked &mut self) -> tracked resource : &mut I::Resource
pub proof fn tracked_borrow_mut_resource(tracked &mut self) -> tracked resource : &mut I::Resource
*resource == old(self).resource(),final(self).resource() == *final(resource),final(self).value() == old(self).value(),final(self).constant() == old(self).constant(),Mutably borrows the user-supplied tracked resource.
Source§impl<'a, T, G: SpinGuardian, I: ResourceInvariant<T>> SpinLockGuard<'a, T, G, I>
impl<'a, T, G: SpinGuardian, I: ResourceInvariant<T>> SpinLockGuard<'a, T, G, I>
Trait Implementations§
Source§impl<T, G: SpinGuardian, I: ResourceInvariant<T>> Deref for SpinLockGuard<'_, T, G, I>
impl<T, G: SpinGuardian, I: ResourceInvariant<T>> Deref for SpinLockGuard<'_, T, G, I>
Source§impl<T, G: SpinGuardian, I: ResourceInvariant<T>> DerefMut for SpinLockGuard<'_, T, G, I>
impl<T, G: SpinGuardian, I: ResourceInvariant<T>> DerefMut for SpinLockGuard<'_, T, G, I>
impl<T: ?Sized, G: SpinGuardian, I: ResourceInvariant<T>> !Send for SpinLockGuard<'_, T, G, I>
impl<T: Sync, G: SpinGuardian, I: ResourceInvariant<T>> Sync for SpinLockGuard<'_, T, G, I>
Auto Trait Implementations§
impl<'a, T, G, I> Freeze for SpinLockGuard<'a, T, G, I>
impl<'a, T, G, I = TrivialResourceInvariant> !RefUnwindSafe for SpinLockGuard<'a, T, G, I>
impl<'a, T, G, I> Unpin for SpinLockGuard<'a, T, G, I>
impl<'a, T, G, I> UnsafeUnpin for SpinLockGuard<'a, T, G, I>
impl<'a, T, G, I = TrivialResourceInvariant> !UnwindSafe for SpinLockGuard<'a, T, G, I>
Blanket Implementations§
Source§impl<T> DerefSpec for Twhere
T: Deref,
impl<T> DerefSpec for Twhere
T: Deref,
Source§fn deref_spec(&self) -> &<T as Deref>::Target
fn deref_spec(&self) -> &<T as Deref>::Target
If you can, do not use this module as it adds assumptions about the core of Rust’s deref semantics.
Source§fn deref_spec_eq(&self)
fn deref_spec_eq(&self)
If you can, do not use this module as it adds assumptions about the core of Rust’s deref semantics.