enable c++17 parallel algorithms through TBB
authorMichael Wallner <mike@php.net>
Fri, 30 Oct 2020 19:54:58 +0000 (20:54 +0100)
committerMichael Wallner <mike@php.net>
Fri, 30 Oct 2020 19:54:58 +0000 (20:54 +0100)
test/CMakeLists.txt
test/lib/Cluster.cpp

index bd865f36d51a0c850dbfc4d364e8122d83d43693..4538512f6950aa9a62a473ba3d34b06e4915fd06 100644 (file)
@@ -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)
index 1186077b2b945187a4042041b00b211e399789b2..1589e68ccf6906f9f699b4924ba5e00289a0a937 100644 (file)
@@ -2,6 +2,9 @@
 #include "Retry.hpp"
 
 #include <algorithm>
+#if HAVE_EXECUTION
+#  include <execution>
+#endif
 #include <sys/wait.h>
 
 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();
   });
 }