Skip to content

NoxxGames/MPMCQueueLocklessCPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 

Repository files navigation

C++ Lockless MP/MC Queue

A simple Multi-Producer, Multi-Consumer Queue Type. Written in Cpp using just atomics with memory barriers to keep everything ordered appropriately.

Inspiration is taken from the LMAX Disruptor. If you're unfamiliar with lockless programming and/or the usage of atomics with memory barriers, then the Disruptor is a great place to start learning.

Usage

First create a new queue as follows:

#include "LocklessMPMCQueue.h"

// Create a new queue of type int, with a desired size of 1500
// size is automatically rounded up to the nearest power of two.
// so the queue size will be 2048 in this case.
lockless_mpmc_queue<int, 1500> my_queue;

Then to add a new element:

my_queue.push(5);

To claim an element:

int my_integer = 0;
my_queue.pop(MyInteger);

About

A simple Lockless Multi-Producer, Multi-Consumer Queue Type. Written in Cpp.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages