Struct sp_runtime::offchain::storage_lock::StorageLock [−][src]
Storage based lock.
A lock that is persisted in the DB and provides the ability to guard against
concurrent access in an off-chain worker, with a defined expiry deadline
based on the concrete Lockable
implementation.
Implementations
impl<'a, L: Lockable + Default> StorageLock<'a, L>
[src]
pub fn new(key: &'a [u8]) -> Self
[src]
Create a new storage lock with a default()
instance of type L
.
impl<'a, L: Lockable> StorageLock<'a, L>
[src]
pub fn with_lockable(key: &'a [u8], lockable: L) -> Self
[src]
Create a new storage lock with an explicit instance of a lockable L
.
pub fn try_lock(
&mut self
) -> Result<StorageLockGuard<'a, '_, L>, <L as Lockable>::Deadline>
[src]
&mut self
) -> Result<StorageLockGuard<'a, '_, L>, <L as Lockable>::Deadline>
A single attempt to lock using the storage entry.
Returns a lock guard on success, otherwise an error containing the
<Self::Lockable>::Deadline
in for the currently active lock
by another task Err(<L as Lockable>::Deadline)
.
pub fn lock(&mut self) -> StorageLockGuard<'a, '_, L>
[src]
Repeated lock attempts until the lock is successfully acquired.
If one uses fn forget(..)
, it is highly likely fn try_lock(..)
is the correct API to use instead of fn lock(..)
, since that might
never unlock in the anticipated span i.e. when used with BlockAndTime
during a certain block number span.
impl<'a> StorageLock<'a, Time>
[src]
pub fn with_deadline(key: &'a [u8], expiration_duration: Duration) -> Self
[src]
Explicitly create a time based storage lock with a non-default expiration timeout.
impl<'a, B> StorageLock<'a, BlockAndTime<B>> where
B: BlockNumberProvider,
[src]
B: BlockNumberProvider,
pub fn with_block_and_time_deadline(
key: &'a [u8],
expiration_block_number_offset: u32,
expiration_duration: Duration
) -> Self
[src]
key: &'a [u8],
expiration_block_number_offset: u32,
expiration_duration: Duration
) -> Self
Explicitly create a time and block number based storage lock with a non-default expiration duration and block number offset.
pub fn with_block_deadline(
key: &'a [u8],
expiration_block_number_offset: u32
) -> Self
[src]
key: &'a [u8],
expiration_block_number_offset: u32
) -> Self
Explicitly create a time and block number based storage lock with the default expiration duration and a non-default block number offset.
Auto Trait Implementations
impl<'a, L> RefUnwindSafe for StorageLock<'a, L> where
L: RefUnwindSafe,
L: RefUnwindSafe,
impl<'a, L> Send for StorageLock<'a, L> where
L: Send,
L: Send,
impl<'a, L> Sync for StorageLock<'a, L> where
L: Sync,
L: Sync,
impl<'a, L> Unpin for StorageLock<'a, L> where
L: Unpin,
L: Unpin,
impl<'a, L> UnwindSafe for StorageLock<'a, L> where
L: UnwindSafe,
L: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CheckedConversion for T
[src]
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
[src]
Self: TryFrom<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
[src]
Self: TryInto<T>,
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, Outer> IsWrappedBy<Outer> for T where
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
[src]
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
pub fn from_ref(outer: &Outer) -> &T
[src]
Get a reference to the inner from the outer.
pub fn from_mut(outer: &mut Outer) -> &mut T
[src]
Get a mutable reference to the inner from the outer.
impl<T> MaybeRefUnwindSafe for T where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> SaturatedConversion for T
[src]
pub fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
[src]
Self: UniqueSaturatedFrom<T>,
pub fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
[src]
Self: UniqueSaturatedInto<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
[src]
T: UncheckedFrom<S>,
pub fn unchecked_into(self) -> T
[src]
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
[src]
T: Bounded,
S: TryInto<T>,
pub fn unique_saturated_into(self) -> T
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,