pub struct ConcurrentReplayBuffer { /* private fields */ }Expand description
Thread-safe concurrent replay buffer backed by parking_lot::Mutex.
Multiple actor threads can push transitions concurrently. A single learner thread samples batches.
parking_lot::Mutex is ~2x faster than std::Mutex on uncontended locks
(~10ns), which is negligible compared to the data copy cost of each push.
§Thread Safety
Automatically Send + Sync because Mutex<T: Send> is Send + Sync.
Implementations§
Source§impl ConcurrentReplayBuffer
impl ConcurrentReplayBuffer
Sourcepub fn new(capacity: usize, obs_dim: usize, act_dim: usize) -> Self
pub fn new(capacity: usize, obs_dim: usize, act_dim: usize) -> Self
Create a concurrent replay buffer with fixed capacity.
All arrays are pre-allocated inside the inner ReplayBuffer.
obs_dim and act_dim define the per-transition dimensionality.
Sourcepub fn push(
&self,
obs: &[f32],
next_obs: &[f32],
action: &[f32],
reward: f32,
terminated: bool,
truncated: bool,
) -> Result<(), RloxError>
pub fn push( &self, obs: &[f32], next_obs: &[f32], action: &[f32], reward: f32, terminated: bool, truncated: bool, ) -> Result<(), RloxError>
Push a transition into the buffer from borrowed slices.
Thread-safe: multiple threads may call push concurrently.
Auto Trait Implementations§
impl !Freeze for ConcurrentReplayBuffer
impl !RefUnwindSafe for ConcurrentReplayBuffer
impl Send for ConcurrentReplayBuffer
impl Sync for ConcurrentReplayBuffer
impl Unpin for ConcurrentReplayBuffer
impl UnwindSafe for ConcurrentReplayBuffer
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more