From: Michael Wallner Date: Fri, 30 Oct 2020 19:54:58 +0000 (+0100) Subject: enable c++17 parallel algorithms through TBB X-Git-Tag: 1.1.0-beta1~140^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=541734c10c8be76478a5004bf1282382efe72135;p=awesomized%2Flibmemcached enable c++17 parallel algorithms through TBB --- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bd865f36..4538512f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,8 +12,14 @@ endif() check_decl(pipe2 unistd.h) check_decl(SOCK_NONBLOCK sys/socket.h) check_decl(SOCK_CLOEXEC sys/socket.h) + check_header(execution) +# TBBConfig only sets TBB_FOUND to FALSE +set(TBB_FOUND TRUE) +set(TBB_FIND_RELEASE_ONLY TRUE) +find_package(TBB) + file(GLOB_RECURSE TESTING_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) set(TESTING_ROOT ${CMAKE_CURRENT_BINARY_DIR}) set_source_files_properties(main.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) @@ -26,6 +32,11 @@ target_include_directories(runtests PRIVATE ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src) target_link_libraries(runtests PRIVATE libhashkit libmemcachedinternal libmemcachedutil) +if(TBB_FOUND AND HAVE_EXECUTION) + target_link_libraries(runtests PRIVATE TBB::tbb) +else() + set(HAVE_EXECUTION 0) +endif() add_dependencies(runtests ${CLIENTS}) if(HAVE_MEMASLAP) add_dependencies(runtests memaslap) diff --git a/test/lib/Cluster.cpp b/test/lib/Cluster.cpp index 1186077b..1589e68c 100644 --- a/test/lib/Cluster.cpp +++ b/test/lib/Cluster.cpp @@ -2,6 +2,9 @@ #include "Retry.hpp" #include +#if HAVE_EXECUTION +# include +#endif #include Cluster::Cluster(Server serv, size_t cnt) @@ -66,7 +69,7 @@ bool Cluster::isListening() const { #if HAVE_EXECUTION execution::par, #endif - cluster.cbegin(), cluster.cend(), [](const Server &s) { + cluster.begin(), cluster.end(), [](const Server &s) { return s.isListening(); }); }