diff --git a/FEXHeaderUtils/FEXHeaderUtils/RingBuffer.h b/FEXHeaderUtils/FEXHeaderUtils/RingBuffer.h new file mode 100644 index 000000000..2e171ea6f --- /dev/null +++ b/FEXHeaderUtils/FEXHeaderUtils/RingBuffer.h @@ -0,0 +1,21 @@ +#pragma once +#include +#include + +namespace FHU { +// This is a fast thread-local non-blocking ring-buffer. +// Very useful for debugging purposes to see the history of something. +template +requires (std::has_single_bit(Elements) && std::is_trivially_copyable_v) +class [[deprecated("Not for production use")]] NonBlockRingBuffer final { +public: + void emplace(T Val) { + Ring[Current] = Val; + Current = (Current + 1) & (Elements - 1); + } + +private: + T Ring[Elements] {}; + size_t Current {}; +}; +} // namespace FHU