Trait arc_swap::access::DynAccess[][src]

pub trait DynAccess<T> {
    fn load(&self) -> DynGuard<T>;
}

An object-safe version of the Access trait.

This can be used instead of the Access trait in case a type erasure is desired. This has the effect of performance hit (due to boxing of the result and due to dynamic dispatch), but makes certain code simpler and possibly makes the executable smaller.

This is automatically implemented for everything that implements Access.

Examples

extern crate arc_swap;

use std::thread;

use arc_swap::access::{Constant, DynAccess};

fn do_something(value: Box<dyn DynAccess<usize> + Send>) {
    thread::spawn(move || {
        let v = value.load();
        println!("{}", *v);
    });
}

do_something(Box::new(Constant(42)));

Required methods

fn load(&self) -> DynGuard<T>[src]

The equivalent of Access::load.

Loading content...

Implementors

impl<T, A> DynAccess<T> for A where
    A: Access<T>,
    A::Guard: 'static, 
[src]

Loading content...