Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T> class double_buffer {
- T buffers[2];
- volatile std::size_t index;
- public:
- double_buffer()
- : index(1) {}
- T& GetFirst() {
- return buffers[index];
- }
- T& GetSecond() {
- return buffers[!index];
- }
- void flip() {
- InterlockedXor(&index, 1);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement