yangyang233333 / MPSC_Queue

A multi-producer single consumer queue C++ template suitable for async logging with SHM IPC support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MPSC_Queue

MPSC_Queue is based on single linked list. Producers have the queue allocate a msg object, set msg content and push it back to the queue; Consumer pops all msgs from the queue at a time, processes them and gives the objects back to the queue for later allocation from producers. So neither producer nor consumer needs to allocate memory themselves and no memory copy is needed in any of the operations.

There're two versions of implementation:

MPSCQueue(mpsc_queue.h)

MPSCQueue is for single process usage, it allows for configurating a pre-allocated msg size and max allocated msg size at run time.

SHMMPSCQueue(shm_mpsc_queue.h)

SHMMPSCQueue can reside in shared memory, thus suitable for IPC, and the msg size is fixed at compile time.

Examples

test provides a simple test program and a full fledged async logging implementation(based on muduo), for both versions.

About

A multi-producer single consumer queue C++ template suitable for async logging with SHM IPC support

License:MIT License


Languages

Language:C++ 98.2%Language:C 0.9%Language:Shell 0.9%