[][src]Struct tokio::sync::Lock

pub struct Lock<T> { /* fields omitted */ }

An asynchronous mutual exclusion primitive useful for protecting shared data

Each mutex has a type parameter (T) which represents the data that it is protecting. The data can only be accessed through the RAII guards returned from lock, which guarantees that the data is only ever accessed when the mutex is locked.

Methods

impl<T> Lock<T>[src]

pub fn new(t: T) -> Lock<T>[src]

Creates a new lock in an unlocked state ready for use.

pub fn lock(&'_ mut self) -> impl Future<Output = LockGuard<T>>[src]

A future that resolves on acquiring the lock and returns the LockGuard.

Trait Implementations

impl<T> Sync for Lock<T> where
    T: Send
[src]

impl<T> Debug for Lock<T> where
    T: Debug
[src]

impl<T> Send for Lock<T> where
    T: Send
[src]

impl<T> Clone for Lock<T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T> Default for Lock<T> where
    T: Default
[src]

impl<T> From<T> for Lock<T>[src]

Auto Trait Implementations

impl<T> Unpin for Lock<T>

impl<T> !UnwindSafe for Lock<T>

impl<T> !RefUnwindSafe for Lock<T>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]