#buffer #generic #algorithm #data-structures #no-alloc #array

no-std double-buffer

A simple double buffer generic implementation

5 releases (1 stable)

1.0.0 Nov 16, 2023
0.3.1 Oct 4, 2023
0.3.0 Sep 27, 2023
0.2.0 Sep 27, 2023
0.1.0 Sep 26, 2023

#1421 in Algorithms

Download history 5/week @ 2024-02-19 4/week @ 2024-02-26 3/week @ 2024-03-11 93/week @ 2024-04-01

96 downloads per month

Unlicense

14KB
248 lines

Generic and simple double buffer

This only provides DoubleBuffer<T>, for implementing a double buffer pattern.

DoubleBuffer<T> is not limited to bytes arrays or similar buffers, it can be used with any type that requires modify while reading current state and all the changes look as one atomic operation.

Swapping Benchmarks

The following are the results in a i7 10th gen with 32GB RAM for a vec![0u8; 16777216] buffer:

  1. DoubleBuffer::swap() - 1.6655 ns 1.6814 ns 1.6964 ns
  2. DoubleBuffer::swap_with_default() - 1.7547 ns 1.8009 ns 1.8262 ns
  3. DoubleBuffer::swap_with_clone() - 4.4526 ms 4.5241 ms 4.5989 ms

No runtime deps