Coder Social home page Coder Social logo

skyformat99 / ring-buffer-3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jnk0le/ring-buffer

0.0 0.0 0.0 65 KB

simple C++11 ring buffer implementation, allocated and evaluated at compile time

License: Creative Commons Zero v1.0 Universal

C++ 100.00%

ring-buffer-3's Introduction

Ring Buffer

  • pure C++11, no OS dependency
  • no exceptions, RTTI, virtual functions and dynamic memory allocation
  • designed for compile time (static) allocation and type evaluation
  • no wasted slots (in powers of 2 granularity)
  • lock and wait free SPSC operation
  • underrun and overrun checks in insert/remove functions
  • highly efficient on most microcontroller architectures (nearly equal performance as in 'wasted-slot' implemetation)

notes

  • index_t of size less than architecture reg size (size_t) might not be most efficient (known gcc bug)
  • Only lamda expressions or functor callbacks can be inlined into buffWrite/buffRead functions
  • 8 bit architectures are not supported in master branch at the moment. Broken code is likely to be generated
  • relaxed atomic stores on RISC-V gcc port may be inefficient
  • the DEC Alpha ultra-weak memory model is not supported

example

jnk0le::Ringbuffer<const char*, 256> message;

int main()
{
	//...
	while(1)
	{
		const char* tmp = nullptr;
		while(!message.remove(tmp));
		printf("%s fired\n", tmp);
		//...
	}
}

extern "C" void SysTick_Handler(void)
{
	message.insert("SysTick_Handler");
}

ring-buffer-3's People

Contributors

jnk0le avatar swithers-airo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.