Struct factory::SwappableFactory
[−]
[src]
pub struct SwappableFactory<T>(_);
#[cfg(feature = "swappable")]
A Factory
that allows for swapping inner factories dynamically.
This use a lock-free data structure for swapping.
Examples
use factory::{CloneFactory, Factory, SwappableFactory}; let f0 = SwappableFactory::new(CloneFactory::new(32)); let f1 = f0.clone(); assert_eq!(f0.create(), 32); assert_eq!(f1.create(), 32); f0.swap(CloneFactory::new(50)); assert_eq!(f0.create(), 50); assert_eq!(f1.create(), 50);
Methods
impl<T: Factory> SwappableFactory<T>
[src]
pub fn new(inner: T) -> Self
[src]
Makes a new SwappableFactory
with the initial inner factory.
pub fn get(&self) -> Arc<T>
[src]
Returns the currently used factory.
pub fn swap(&self, new: T) -> Arc<T>
[src]
Updates inner factory by new
, and returns old one.
This operation affects all SwappableFactory
instances cloned from the original one.
Trait Implementations
impl<T: Debug> Debug for SwappableFactory<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: Default> Default for SwappableFactory<T>
[src]
fn default() -> SwappableFactory<T>
[src]
Returns the "default value" for a type. Read more
impl<T: Factory> Factory for SwappableFactory<T>
[src]
type Item = T::Item
The type of instances created by this factory.
fn create(&self) -> Self::Item
[src]
Creates an instance.
impl<T> Clone for SwappableFactory<T>
[src]
Auto Trait Implementations
impl<T> Send for SwappableFactory<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Sync for SwappableFactory<T> where
T: Send + Sync,
T: Send + Sync,