dnedic / lockfree Goto Github PK
View Code? Open in Web Editor NEWA collection of lock-free data structures written in standard C++11
License: MIT License
A collection of lock-free data structures written in standard C++11
License: MIT License
lockfree::mpmc::Queue<int16_t> queue(20);
First of all, thanks for the great library.
I'm [possibly] planning to use it, but I'm just wondering about one thing...
Looking at the tests, it seems like they aren't done using multiple threads, but rather on a single one.
Am I missing something?
In order to help both users, curious bystanders or people looking to contribute, we should have sections explaining how data structures work under the hood, prefferably with diagrams included.
For data structures that are widely used and documented, like the spsc::Queue
, it might not be necessary.
tests/CMakeLists.txt
contains the following lines:
# Required in order to test the std::span API as well
target_compile_features(tests PRIVATE cxx_std_20)
In particular, the tests do not compile with gcc-10
.
I add this project as a subproject into my code. But occur compile error:
"[build] In file included from /home/host/work/cpp/cppcore11/depend/lockfree/lockfree/lockfree.hpp:54:0,
[build] from /home/host/work/cpp/cppcore11/gtest/lock_free_test.cc:1:
[build] /home/host/work/cpp/cppcore11/depend/lockfree/lockfree/spsc/bipartite_buf.hpp:106:10: error: ‘pair’ in namespace ‘std’ does not name a template type
[build] std::pair<T , size_t> ReadAcquire();
[build] ^~~~
[build] In file included from /home/host/work/cpp/cppcore11/depend/lockfree/lockfree/spsc/bipartite_buf.hpp:163:0,
[build] from /home/host/work/cpp/cppcore11/depend/lockfree/lockfree/lockfree.hpp:54,
[build] from /home/host/work/cpp/cppcore11/gtest/lock_free_test.cc:1:
[build] /home/host/work/cpp/cppcore11/depend/lockfree/lockfree/spsc/bipartite_buf_impl.hpp:114:59: error: no ‘std::pair<T, long unsigned int> lockfree::spsc::BipartiteBuf<T, size>::ReadAcquire()’ member function declared in class ‘lockfree::spsc::BipartiteBuf<T, size>’
[build] std::pair<T *, size_t> BipartiteBuf<T, size>::ReadAcquire() {
[build] ^
[build] Scanning dependencies of target gmock_main
[build] [ 41%] Building CXX object depend/googletest/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
[build] make[2]: *** [CMakeFiles/base_unittest.dir/build.make:115: CMakeFiles/base_unittest.dir/gtest/lock_free_test.cc.o] Error 1
[build] make[1]: *** [CMakeFiles/Makefile2:170: CMakeFiles/base_unittest.dir/all] Error 2
[build] make[1]: *** Waiting for unfinished jobs...."
My env:
GCC: 7.5.0
System: Ubuntu 20.04
I fixed this error by add header file "utility" to "bipartitte_buf.hpp"
https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170
Using the /Zc:__cplusplus compiler option forces visual studio to set this macro properly.
NOTE: I was able to add lockfree to a project with C++17 support using CPMAddPackage with the following:
CPMAddPackage(
NAME lockfree
GITHUB_REPOSITORY DNedic/lockfree
GIT_TAG 2.0.2
)
if (lockfree_ADDED AND MSVC)
target_compile_options(lockfree INTERFACE "/Zc:__cplusplus")
endif()
Hey,
Can support be added to the Ring Buffer to support variable length string data? Maybe add a length of the string as the metadata at the start followed by the data?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.