12 std::atomic<T*> to_read{&data[0]};
13 std::atomic<T*> buffer{&data[1]};
14 std::atomic<T*> to_write{&data[2]};
16 std::atomic_flag stale;
19 explicit triple_buffer(T init)
22 data[1] = std::move(init);
31 auto& old = *to_write.load();
35 auto p = buffer.exchange(to_write);
45 if(stale.test_and_set())
49 auto p = buffer.exchange(to_read);
57 auto& get_data() noexcept {
return this->data; }