MayaPosch / LockFreeRingBuffer

Implementation of a lock-free ring buffer class.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lock-free ring buffer

This is an implementation of a lock-free ring buffer, using only C++11 STL level features. Originally designed for the NymphCast project, it supports a single reader & writer model.

It can be used both for a continuous data stream, as well as for a specific data length (file length).

Usage

The project is contained in a single static class (DataBuffer), which can be used as implemented in the test found in the test/ folder.

Usage and underlying theory of the ring buffer has been covered in this blog post.

Test

In the test/test_databuffer_multi_port.cpp file a multi-threaded implementation is created that sets up the DataBuffer, starts a data request and data write thread, followed by starting a dummy reader that drives the constant reading from and writing to of data in the ring buffer.

This test requires C++14 (std::chrono features).

About

Implementation of a lock-free ring buffer class.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C++ 98.8%Language:Makefile 1.2%