[]Struct dtn7::STORE

pub struct STORE { /* fields omitted */ }

Methods from Deref<Target = Mutex<Box<dyn BundleStore + Send>>>

pub fn lock(&self) -> Result<MutexGuard<T>, PoisonError<MutexGuard<T>>>1.0.0[src]

Acquires a mutex, blocking the current thread until it is able to do so.

This function will block the local thread until it is available to acquire the mutex. Upon returning, the thread is the only thread with the lock held. An RAII guard is returned to allow scoped unlock of the lock. When the guard goes out of scope, the mutex will be unlocked.

The exact behavior on locking a mutex in the thread which already holds the lock is left unspecified. However, this function will not return on the second call (it might panic or deadlock, for example).

Errors

If another user of this mutex panicked while holding the mutex, then this call will return an error once the mutex is acquired.

Panics

This function might panic when called if the lock is already held by the current thread.

Examples

use std::sync::{Arc, Mutex};
use std::thread;

let mutex = Arc::new(Mutex::new(0));
let c_mutex = mutex.clone();

thread::spawn(move || {
    *c_mutex.lock().unwrap() = 10;
}).join().expect("thread::spawn failed");
assert_eq!(*mutex.lock().unwrap(), 10);

pub fn try_lock(&self) -> Result<MutexGuard<T>, TryLockError<MutexGuard<T>>>1.0.0[src]

Attempts to acquire this lock.

If the lock could not be acquired at this time, then Err is returned. Otherwise, an RAII guard is returned. The lock will be unlocked when the guard is dropped.

This function does not block.

Errors

If another user of this mutex panicked while holding the mutex, then this call will return failure if the mutex would otherwise be acquired.

Examples

use std::sync::{Arc, Mutex};
use std::thread;

let mutex = Arc::new(Mutex::new(0));
let c_mutex = mutex.clone();

thread::spawn(move || {
    let mut lock = c_mutex.try_lock();
    if let Ok(ref mut mutex) = lock {
        **mutex = 10;
    } else {
        println!("try_lock failed");
    }
}).join().expect("thread::spawn failed");
assert_eq!(*mutex.lock().unwrap(), 10);

pub fn is_poisoned(&self) -> bool1.2.0[src]

Determines whether the mutex is poisoned.

If another thread is active, the mutex can still become poisoned at any time. You should not trust a false value for program correctness without additional synchronization.

Examples

use std::sync::{Arc, Mutex};
use std::thread;

let mutex = Arc::new(Mutex::new(0));
let c_mutex = mutex.clone();

let _ = thread::spawn(move || {
    let _lock = c_mutex.lock().unwrap();
    panic!(); // the mutex gets poisoned
}).join();
assert_eq!(mutex.is_poisoned(), true);

Trait Implementations

impl Deref for STORE

type Target = Mutex<Box<dyn BundleStore + Send>>

The resulting type after dereferencing.

impl LazyStatic for STORE

Auto Trait Implementations

impl Send for STORE

impl Sync for STORE

impl Unpin for STORE

impl UnwindSafe for STORE

impl RefUnwindSafe for STORE

Blanket Implementations

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

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

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]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

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

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