Struct vstd::rwlock::RwLockToks::Instance

source ·
pub struct Instance<K, V, Pred: InvariantPredicate<K, V>> { /* private fields */ }

Implementations§

source§

impl<K, V, Pred: InvariantPredicate<K, V>> Instance<K, V, Pred>

source

pub fn clone(&self) -> Self

source

pub fn id(&self) -> InstanceId

source

pub fn k(&self) -> K

source

pub fn pred(&self) -> PhantomData<Pred>

source

pub proof fn initialize_full( k: K, t: V, tracked param_token_storage: Option<V> ) -> tracked tmp_tuple : (Tracked<Instance<K, V, Pred>>, Tracked<flag_exc<K, V, Pred>>, Tracked<flag_rc<K, V, Pred>>, Tracked<Option<pending_writer<K, V, Pred>>>, Tracked<Option<writer<K, V, Pred>>>, Tracked<MultisetToken<(), pending_reader<K, V, Pred>>>, Tracked<MultisetToken<V, reader<K, V, Pred>>>)

requires
(Pred::inv(k, t)),
(crate::prelude::equal(param_token_storage, Option::Some(t))),
ensures
({
    let (
        instance,
        param_token_flag_exc,
        param_token_flag_rc,
        param_token_pending_writer,
        param_token_writer,
        param_token_pending_reader,
        param_token_reader,
    ) = tmp_tuple;
    let instance = instance.view();
    let param_token_flag_exc = param_token_flag_exc.view();
    let param_token_flag_rc = param_token_flag_rc.view();
    let param_token_pending_writer = param_token_pending_writer.view();
    let param_token_writer = param_token_writer.view();
    let param_token_pending_reader = param_token_pending_reader.view();
    let param_token_reader = param_token_reader.view();
    (crate::prelude::equal((param_token_flag_exc).instance_id(), instance.id()))
        && (crate::prelude::equal((param_token_flag_rc).instance_id(), instance.id()))
        && (crate::prelude::equal((instance).k(), k))
        && (crate::prelude::equal((instance).pred(), PhantomData))
        && (crate::prelude::equal(param_token_flag_exc.value(), false))
        && (crate::prelude::equal(param_token_flag_rc.value(), 0))
        && (crate::tokens::option_value_eq_option_token(
            Option::None,
            param_token_pending_writer,
            instance.id(),
        ))
        && (crate::tokens::option_value_eq_option_token(
            Option::None,
            param_token_writer,
            instance.id(),
        ))
        && (crate::prelude::equal(
            Multiset::empty(),
            (param_token_pending_reader).multiset(),
        )
            && crate::prelude::equal(
                (param_token_pending_reader).instance_id(),
                instance.id(),
            ))
        && (crate::prelude::equal(Multiset::empty(), (param_token_reader).multiset())
            && crate::prelude::equal((param_token_reader).instance_id(), instance.id()))
}),
source

pub proof fn acquire_read_start(tracked &self, tracked param_token_flag_rc: &mut flag_rc<K, V, Pred> ) -> tracked param_token_0_pending_reader : pending_reader<K, V, Pred>

requires
(crate::prelude::equal(
    crate::prelude::old(param_token_flag_rc).instance_id(),
    (*self).id(),
)),
ensures
(crate::prelude::equal(param_token_flag_rc.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_pending_reader.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_pending_reader.element(), ())),
(crate::prelude::equal(
    param_token_flag_rc.value(),
    crate::prelude::old(param_token_flag_rc).value() + 1,
)),
source

pub proof fn acquire_read_end(tracked &self, tracked param_token_flag_exc: &flag_exc<K, V, Pred>, tracked param_token_0_pending_reader: pending_reader<K, V, Pred> ) -> tracked tmp_tuple : (Ghost<Option<V>>, Tracked<reader<K, V, Pred>>)

requires
(crate::prelude::equal(param_token_flag_exc.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_pending_reader.instance_id(), (*self).id())),
((param_token_flag_exc.value() == false)),
(crate::prelude::equal(param_token_0_pending_reader.element(), ())),
ensures
({
    let (original_field_storage, param_token_1_reader) = tmp_tuple;
    let original_field_storage = original_field_storage.view();
    let param_token_1_reader = param_token_1_reader.view();
    (crate::prelude::equal(param_token_1_reader.instance_id(), (*self).id()))
        && ({
            let x: V = original_field_storage.get_Some_0();
            crate::prelude::equal(param_token_1_reader.element(), x)
        })
        && ({
            let x: V = original_field_storage.get_Some_0();
            Pred::inv(((*self)).k(), x)
        })
}),
source

pub proof fn acquire_read_abandon(tracked &self, tracked param_token_flag_rc: &mut flag_rc<K, V, Pred>, tracked param_token_0_pending_reader: pending_reader<K, V, Pred> )

requires
(crate::prelude::equal(
    crate::prelude::old(param_token_flag_rc).instance_id(),
    (*self).id(),
)),
(crate::prelude::equal(param_token_0_pending_reader.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_pending_reader.element(), ())),
ensures
(crate::prelude::equal(param_token_flag_rc.instance_id(), (*self).id())),
((crate::prelude::old(param_token_flag_rc).value() >= 1)),
(crate::prelude::equal(
    param_token_flag_rc.value(),
    (crate::prelude::old(param_token_flag_rc).value() - 1) as nat,
)),
source

pub proof fn acquire_exc_start(tracked &self, tracked param_token_flag_exc: &mut flag_exc<K, V, Pred> ) -> tracked param_token_0_pending_writer : pending_writer<K, V, Pred>

requires
(crate::prelude::equal(
    crate::prelude::old(param_token_flag_exc).instance_id(),
    (*self).id(),
)),
((crate::prelude::old(param_token_flag_exc).value() == false)),
ensures
(crate::prelude::equal(param_token_flag_exc.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_pending_writer.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_pending_writer.value(), ())),
(crate::prelude::equal(param_token_flag_exc.value(), true)),
source

pub proof fn acquire_exc_end(tracked &self, tracked param_token_flag_rc: &flag_rc<K, V, Pred>, tracked param_token_0_pending_writer: pending_writer<K, V, Pred> ) -> tracked tmp_tuple : (Ghost<Option<V>>, Tracked<V>, Tracked<writer<K, V, Pred>>)

requires
(crate::prelude::equal(param_token_flag_rc.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_pending_writer.instance_id(), (*self).id())),
((param_token_flag_rc.value() == 0)),
(crate::prelude::equal(param_token_0_pending_writer.value(), ())),
ensures
({
    let (original_field_storage, param_token_2_storage, param_token_1_writer) = tmp_tuple;
    let original_field_storage = original_field_storage.view();
    let param_token_2_storage = param_token_2_storage.view();
    let param_token_1_writer = param_token_1_writer.view();
    (crate::prelude::equal(param_token_1_writer.instance_id(), (*self).id()))
        && (crate::prelude::equal(param_token_1_writer.value(), ()))
        && ({
            let x = original_field_storage.get_Some_0();
            crate::prelude::equal(param_token_2_storage, x)
        })
        && ({
            let x = original_field_storage.get_Some_0();
            Pred::inv(((*self)).k(), x)
        })
}),
source

pub proof fn release_exc(tracked &self, x: V, tracked param_token_flag_exc: &mut flag_exc<K, V, Pred>, tracked param_token_1_storage: V, tracked param_token_0_writer: writer<K, V, Pred> )

requires
(crate::prelude::equal(
    crate::prelude::old(param_token_flag_exc).instance_id(),
    (*self).id(),
)),
(crate::prelude::equal(param_token_0_writer.instance_id(), (*self).id())),
(Pred::inv(((*self)).k(), x)),
(crate::prelude::equal(param_token_0_writer.value(), ())),
(crate::prelude::equal(param_token_1_storage, x)),
ensures
(crate::prelude::equal(param_token_flag_exc.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_flag_exc.value(), false)),
source

pub proof fn read_guard<'a>(tracked &self, x: V, tracked param_token_0_reader: &'a reader<K, V, Pred> ) -> tracked param_token_1_storage : &'a V

requires
(crate::prelude::equal(param_token_0_reader.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_reader.element(), x)),
ensures
(crate::prelude::equal(*param_token_1_storage, x)),
source

pub proof fn read_match(tracked &self, x: V, y: V, tracked param_token_0_reader: &reader<K, V, Pred>, tracked param_token_1_reader: &reader<K, V, Pred> )

requires
(crate::prelude::equal(param_token_0_reader.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_1_reader.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_reader.element(), x)),
(crate::prelude::equal(param_token_1_reader.element(), y)),
ensures
((equal(x, y))),
source

pub proof fn release_shared(tracked &self, x: V, tracked param_token_flag_rc: &mut flag_rc<K, V, Pred>, tracked param_token_0_reader: reader<K, V, Pred> )

requires
(crate::prelude::equal(
    crate::prelude::old(param_token_flag_rc).instance_id(),
    (*self).id(),
)),
(crate::prelude::equal(param_token_0_reader.instance_id(), (*self).id())),
(crate::prelude::equal(param_token_0_reader.element(), x)),
ensures
(crate::prelude::equal(param_token_flag_rc.instance_id(), (*self).id())),
((crate::prelude::old(param_token_flag_rc).value() >= 1)),
(crate::prelude::equal(
    param_token_flag_rc.value(),
    (crate::prelude::old(param_token_flag_rc).value() - 1) as nat,
)),

Trait Implementations§

source§

impl<K, V, Pred: InvariantPredicate<K, V>> Clone for Instance<K, V, Pred>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K, V, Pred: InvariantPredicate<K, V>> Copy for Instance<K, V, Pred>

Auto Trait Implementations§

§

impl<K, V, Pred> Freeze for Instance<K, V, Pred>

§

impl<K, V, Pred> RefUnwindSafe for Instance<K, V, Pred>

§

impl<K, V, Pred> Send for Instance<K, V, Pred>
where V: Sync + Send, K: Send, Pred: Send,

§

impl<K, V, Pred> Sync for Instance<K, V, Pred>
where V: Sync + Send, K: Sync, Pred: Sync,

§

impl<K, V, Pred> Unpin for Instance<K, V, Pred>
where V: Unpin, K: Unpin, Pred: Unpin,

§

impl<K, V, Pred> UnwindSafe for Instance<K, V, Pred>
where V: UnwindSafe, K: UnwindSafe, Pred: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.