https://github.com/bhhbazinga/concurrentqueue
ConcurrentQueue implemented in c++, the algorithms involved are also used in Java ConcurrentLinkedQueue (Java Platform SE 8 ).
https://github.com/bhhbazinga/concurrentqueue
concurrent cplusplus lockfree queue thread
Last synced: 4 months ago
JSON representation
ConcurrentQueue implemented in c++, the algorithms involved are also used in Java ConcurrentLinkedQueue (Java Platform SE 8 ).
- Host: GitHub
- URL: https://github.com/bhhbazinga/concurrentqueue
- Owner: bhhbazinga
- Created: 2020-02-24T06:05:56.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-28T05:57:11.000Z (almost 5 years ago)
- Last Synced: 2025-06-03T16:13:37.584Z (7 months ago)
- Topics: concurrent, cplusplus, lockfree, queue, thread
- Language: C++
- Homepage:
- Size: 19.5 KB
- Stars: 23
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ConcurrentQueue
ConcurrentQueue implemented in c++, the algorithms involved are also used in Java ConcurrentLinkedQueue (Java Platform SE 8 ).
## Feature
* Thread-safe and Lock-free.
* Singly-linked list with a sentinel node.
* Support Multi-producer & Multi-consumer.
* Dynamic size.
* Dynamically allocate and deallocate nodes.
* Use [Hazard Pointer with RAII style](https://github.com/bhhbazinga/HazardPointer) to avoid ABA problems and manage memory.
## Benchmark
I've compared it with another ConcurrentLinkedQueue implematation [LockFreeQueue](https://github.com/bhhbazinga/LockFreeQueue), and their efficiency are almost the same.See [test](test.cc).
## Build
```
make && ./test
```
## API
```C++
void Enqueue(const T& data);
void Enqueue(T&& data);
void Emplace(Arg&&... args);
bool Dequeue(T& data);
size_t size() const;
```
## Reference
[1]Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects. Maged M. Michael\
[2]Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms. Maged M. Michael Michael L. Scott