pub struct MemoryStorage<V> { /* private fields */ }Expand description
In-memory trial storage (the default).
Wrap a Vec<CompletedTrial<V>> behind a read-write lock so that
trials can be appended from any thread. This is the backend that
Study uses when no explicit storage is provided.
Use with_trials to seed a study with
previously collected data.
§Example
use optimizer::storage::{MemoryStorage, Storage};
let storage = MemoryStorage::<f64>::new();
assert_eq!(storage.trials_arc().read().len(), 0);Implementations§
Source§impl<V> MemoryStorage<V>
impl<V> MemoryStorage<V>
Sourcepub fn with_trials(trials: Vec<CompletedTrial<V>>) -> Self
pub fn with_trials(trials: Vec<CompletedTrial<V>>) -> Self
Create an in-memory store pre-populated with trials.
The internal ID counter is set to one past the highest trial ID so that subsequent trials receive unique IDs.
Trait Implementations§
Source§impl<V> Default for MemoryStorage<V>
impl<V> Default for MemoryStorage<V>
Source§impl<V: Send + Sync> Storage<V> for MemoryStorage<V>
impl<V: Send + Sync> Storage<V> for MemoryStorage<V>
Source§fn push(&self, trial: CompletedTrial<V>)
fn push(&self, trial: CompletedTrial<V>)
Append a completed trial to the store.
Source§fn trials_arc(&self) -> &Arc<RwLock<Vec<CompletedTrial<V>>>>
fn trials_arc(&self) -> &Arc<RwLock<Vec<CompletedTrial<V>>>>
Return a reference to the in-memory trial buffer. Read more
Source§fn next_trial_id(&self) -> u64
fn next_trial_id(&self) -> u64
Atomically return the next unique trial ID. Read more
Source§fn peek_next_trial_id(&self) -> u64
fn peek_next_trial_id(&self) -> u64
Return the current value of the next-trial-ID counter without incrementing. Read more
Auto Trait Implementations§
impl<V> !Freeze for MemoryStorage<V>
impl<V> !RefUnwindSafe for MemoryStorage<V>
impl<V> Send for MemoryStorage<V>
impl<V> Sync for MemoryStorage<V>
impl<V> Unpin for MemoryStorage<V>
impl<V> !UnwindSafe for MemoryStorage<V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more