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]

[src]

Makes a new SwappableFactory with the initial inner factory.

[src]

Returns the currently used factory.

[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]

[src]

Formats the value using the given formatter. Read more

impl<T: Default> Default for SwappableFactory<T>
[src]

[src]

Returns the "default value" for a type. Read more

impl<T: Factory> Factory for SwappableFactory<T>
[src]

The type of instances created by this factory.

[src]

Creates an instance.

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<T> Send for SwappableFactory<T> where
    T: Send + Sync

impl<T> Sync for SwappableFactory<T> where
    T: Send + Sync