pub struct FramePool { /* private fields */ }Expand description
Buffers handed back for reuse, so steady-state playback allocates nothing.
Decoding 24 frames a second means 24 allocations a second of several megabytes each; at 4K that is enough to keep an allocator busy and enough to fragment one. Frames come back here when the renderer is done with them.
Implementations§
Source§impl FramePool
impl FramePool
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
A pool holding at most capacity buffers.
Bounded on purpose: an unbounded pool is a memory leak that happens to be spelled differently.
Sourcepub fn take(&mut self, size: usize) -> Vec<u8> ⓘ
pub fn take(&mut self, size: usize) -> Vec<u8> ⓘ
A buffer of at least size bytes, cleared to that length.
Sourcepub fn reclaim(&mut self, frame: Frame)
pub fn reclaim(&mut self, frame: Frame)
Takes a frame’s buffer back if nothing else still holds it.
A frame the renderer is still reading is left alone — which is the point
of the Arc: reuse is an optimisation, never a race.
Sourcepub fn statistics(&self) -> (u64, u64)
pub fn statistics(&self) -> (u64, u64)
How many take calls were answered without allocating, and how many
were not. Steady-state playback should stop adding to the second.