https://github.com/bhhbazinga/lockfreelinkedlist
Lock Free Linked List Based On Harris'OrderedListBasedSet And Michael's Hazard Pointer.
https://github.com/bhhbazinga/lockfreelinkedlist
cpp linked-list lock-free thread
Last synced: about 2 months ago
JSON representation
Lock Free Linked List Based On Harris'OrderedListBasedSet And Michael's Hazard Pointer.
- Host: GitHub
- URL: https://github.com/bhhbazinga/lockfreelinkedlist
- Owner: bhhbazinga
- Created: 2020-02-04T07:34:28.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-27T03:12:49.000Z (over 5 years ago)
- Last Synced: 2025-04-17T22:09:00.391Z (2 months ago)
- Topics: cpp, linked-list, lock-free, thread
- Language: C++
- Homepage:
- Size: 47.9 KB
- Stars: 34
- Watchers: 3
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LockFreeLinkedList
Lock Free Linked List Based On Harris'OrderedListBasedSet And Michael's Hazard Pointer.
## Feature
* Thread-safe and Lock-free.
* ABA safe.
* Set implemented through singly ordered linked list[1].
* Use Hazard pointer to manage memory[2].
* Support Multi-producer & Multi-consumer.
## BenchmarkMagnitude | Insert | Delete | Insert & Delete|
:----------- | :-----------| :-----------| :-----------------
1K | 1.2ms | 0ms | 3.6ms
10K | 147.1ms | 18.9ms | 293.5ms
100K | 15064.4ms | 1647ms | 27176ms
The above data was tested on my 2013 macbook-pro with Intel Core i7 4 cores 2.3 GHz.The data of first and second column was obtained by starting 8 threads to insert concurrently and delete concurrently, the data of third column was obtained by starting 4 threads to insert and 4 threads to delete concurrently, each looped 10 times to calculate the average time consumption.
See also [test](test.cc).
## Build
```
make && ./test
```
## API
```C++
bool Insert(const T& data);
bool Insert(T&& data);
bool Emplace(Args&&... args);
bool Delete(const T& data);
bool Find(const T& data);
size_t size() const;
```
## Reference
[1]A Pragmatic Implementation of Non-BlockingLinked-Lists. Timothy L.Harris\
[2]Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects. Maged M. Michael