pub struct DoubleBuffer<T> { /* private fields */ }Expand description
Two-buffer ring. current() is what compute reads this step;
next_mut() is where the next async copy should land. Call
swap() after waiting on the current copy to advance.
Implementations§
Source§impl<T> DoubleBuffer<T>
impl<T> DoubleBuffer<T>
pub fn new(a: T, b: T) -> DoubleBuffer<T>
pub fn current(&self) -> &T
pub fn current_mut(&mut self) -> &mut T
pub fn next(&self) -> &T
pub fn next_mut(&mut self) -> &mut T
Sourcepub fn swap(&mut self)
pub fn swap(&mut self)
Flip which buffer is current. Typical pattern:
// At step k:
engine.wait(prev_token); // copy of tile-k done
let token_for_kp1 = engine.issue(src_kp1, double.next_mut(), bytes);
compute(double.current()); // shader runs on tile-k
double.swap(); // tile-(k+1) becomes current
// → at step k+1, wait(token_for_kp1) etc.Trait Implementations§
Source§impl<T> Clone for DoubleBuffer<T>where
T: Clone,
impl<T> Clone for DoubleBuffer<T>where
T: Clone,
Source§fn clone(&self) -> DoubleBuffer<T>
fn clone(&self) -> DoubleBuffer<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for DoubleBuffer<T>where
T: Freeze,
impl<T> RefUnwindSafe for DoubleBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for DoubleBuffer<T>where
T: Send,
impl<T> Sync for DoubleBuffer<T>where
T: Sync,
impl<T> Unpin for DoubleBuffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for DoubleBuffer<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for DoubleBuffer<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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