All Projects → bhhbazinga → LockFreeQueue

bhhbazinga / LockFreeQueue

Licence: other
Lock Free Queue Based On Hazard Pointer.

Programming Languages

C++
36643 projects - #6 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to LockFreeQueue

isolated-runtime
Run untrusted Javascript code in a multi-tenant, isolated environment
Stars: ✭ 21 (-34.37%)
Mutual labels:  threads
reactphp-parallel
ReactPHP bindings around ext-parallel
Stars: ✭ 15 (-53.12%)
Mutual labels:  threads
WebAssembly-in-Action
Source code for the book "WebAssembly in Action" (https://www.manning.com/books/webassembly-in-action)
Stars: ✭ 44 (+37.5%)
Mutual labels:  threads
iworker
Promise-based wrapper for worker_threads
Stars: ✭ 18 (-43.75%)
Mutual labels:  threads
thread-pool
A modern thread pool implementation based on C++20
Stars: ✭ 104 (+225%)
Mutual labels:  threads
cpp-indicators
A very simple, easy-to-use, and single-header-only C++ library for console based indicators (loading spinners)
Stars: ✭ 13 (-59.37%)
Mutual labels:  threads
WebServer
C++高性能网络服务器
Stars: ✭ 53 (+65.63%)
Mutual labels:  lockfreequeue
futex
File-based Ruby Mutex
Stars: ✭ 14 (-56.25%)
Mutual labels:  threads
wasm-bindgen-rayon
An adapter for enabling Rayon-based concurrency on the Web with WebAssembly.
Stars: ✭ 257 (+703.13%)
Mutual labels:  threads
SwiftConcurrentCollections
Swift Concurrent Collections
Stars: ✭ 40 (+25%)
Mutual labels:  threads
mandelbrot-threaded-webassembly
A simple demonstration of WebAssembly threads
Stars: ✭ 41 (+28.13%)
Mutual labels:  threads
ModernOperatingSystems AndrewTanenbaum
My notes after reading 'Modern Operating Systems' book by Andrew Tanenbaum and Herbert Bos.
Stars: ✭ 71 (+121.88%)
Mutual labels:  threads
gologger
A concurrent, fast queue/service worker based filesystem logging system perfect for servers with concurrent connections
Stars: ✭ 16 (-50%)
Mutual labels:  threads
SACK
System Abstraction Component Kit
Stars: ✭ 18 (-43.75%)
Mutual labels:  threads
ip scan
Scan a list of IPs quickly using multithreading
Stars: ✭ 13 (-59.37%)
Mutual labels:  threads
Example
Metarhia application example for Node.js
Stars: ✭ 147 (+359.38%)
Mutual labels:  threads
audria
audria - A Utility for Detailed Ressource Inspection of Applications
Stars: ✭ 35 (+9.38%)
Mutual labels:  threads
nativescript-http
The best way to do HTTP requests in NativeScript, a drop-in replacement for the core HTTP with important improvements and additions like proper connection pooling, form data support and certificate pinning
Stars: ✭ 32 (+0%)
Mutual labels:  threads
event-worker
A simpler way of dealing with Web Workers
Stars: ✭ 18 (-43.75%)
Mutual labels:  threads
mwt
Medium weight threads - preemptive thread pools for Lwt
Stars: ✭ 28 (-12.5%)
Mutual labels:  threads

LockFreeQueue

Lock Free Queue Based On Hazard Pointer.

Feature

  • Thread-safe and Lock-free.
  • Hazard pointer.
  • ABA safe.
  • Inter thread helping.
  • Singly-linked list with a sentinel node.
  • Support Multi-producer & Multi-consumer.
  • Dynamic size.
  • Dynamically allocate nodes(performance bottlneck). Or you can simply implement a thread-safe memory pool, e.g. by thread_local storage identifier.

Benchmark

Magnitude Enqueue Dequeue Enqueue & Dequeue
10K 1.8ms 1.4ms 2.6ms
100K 33.6ms 32.3ms 38.6ms
1000K 209.2ms 185.1ms 299.3ms

The above data was tested on my i5-7500 cpu with gcc -O3.
You can also compare the tested data with BlockingQueue which is implemented by mutex.

The data of first and second column was obtained by starting 4 threads to enqueue concurrently and dequeue concurrently, the data of third column was obtained by starting 2 threads to enqueue and 2 threads to dequeue concurrently, each looped 10 times to calculate the average time consumption. See also test.

Build

make && ./test

API

void Enqueue(const T& data);
void Enqueue(T&& data);
void Emplace(Args&&... args);
bool Dequeue(T& data);
size_t size() const;

Reference

Lock-Free Data Structures with Hazard Pointers
C++ Concurrency in Action, Second Edition

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].