• Stars
    star
    242
  • Rank 167,048 (Top 4 %)
  • Language
    C++
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A highly optimized single producer single consumer message queue C++ template

SPSC_Queue

A single producer single consumer lock-free queue C++ template for ultimate low latency, which can be used in multithread conmunication as well as in shared memory IPC under Linux.

The latency of communication of a 10-200B message is within 50-100 ns between two cpu cores on the same node. Sender and receiver don't need to copy a single byte of the msg, that is, a msg is allocated in the queue memory and set by sender, then read directly by the receiver in another thread/process.

This Library mainly contains 4 C++ templates, 2 for single typed queue and 2 for variant typed queue:

SPSCQueue.h

An atomic(crash safe when used in shared-memory IPC) single typed queue template.

SPSCQueueOPT.h

An optimized implementation of SPSCQueue, in which each msg has an additional bool header and write_idx and read_idx are not shared between threads. Note that Push() and Pop() operation are not atomic so it should not be used in IPC.

SPSCVarQueue.h

An atomic(crash safe when used in shared-memory IPC) general purpose variant typed queue template, with a header before each msg. This queue is used in TCPSHM: a connection-oriented persistent message queue framework based on TCP or SHM .

SPSCVarQueueOPT.h

An optimized implementation of SPSCVarQueue, in which reader doens't need to read write_idx so latency is reduced when new msg comes. Note that SPSCVarQueueOPT is not atomic.

Test

shmq_recv.cc/shmq_send.cc

A shared memory IPC example for testing SPSCQueue/SPSCQueueOPT.

multhread_q.cc

A multi-thread example for testing SPSCQueue/SPSCQueueOPT.

multhread_varq.cc

A multi-thread example for testing SPSCVarQueue/SPSCVarQueueOPT

More Repositories

1

fmtlog

fmtlog is a performant fmtlib-style logging library with latency in nanoseconds.
C++
768
star
2

tcpshm

A connection-oriented persistent message queue framework based on TCP or SHM(shared memory)
C++
454
star
3

tscns

A low overhead nanosecond clock based on x86 TSC
C++
286
star
4

pollnet

A collection of non-blocking(polling) network libs for Linux, also support solarflare APIs(Tcpdirect/Efvi)
C++
208
star
5

websocket

A single header c++ websocket client/server lib for linux
C++
165
star
6

str

A SIMD optimized fixed-length string class along with an adaptive hash table for fast searching
C++
124
star
7

WFMPMC

A bounded wait-free(almost) zero-copy MPMC queue written in C++11, which can also reside in SHM for IPC
C++
109
star
8

TCP-UDP-Proxy

A proxy server program written in C++ that can forward TCP or UDP packets
C++
87
star
9

SPMC_Queue

A simple and efficient single producer multiple consumer queue, suititable for both ITC and IPC.
C++
76
star
10

MPSC_Queue

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

PubSubQueue

An efficient single publisher multiple subscriber message queue for Linux IPC
C++
54
star
12

admincmd

A shell style command line framework which can easily be incorporated into a linux c++ server, supporting telnet/nc clients
C++
38
star
13

NanoLogLite

A revised version of NanoLog which writes human readable log file, and is easier to use.
C++
36
star
14

efvitcp

A Tcp/Ip stack implementation on top of Solarflare ef_vi, and a C++ headers only framework for tcp multiplexing client/server.
30
star
15

Algos

A collection of C++ libraries I personally maintained and used in competitive programming problems.
C++
4
star
16

SuperImageView-for-Android

A powerful Image browser for Android that supports multiple gestures
Java
1
star