From a83851bd05393ce0150923fc20899cf1a6ca33a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20S=2E=20Ga=C3=9Fmann?= Date: Thu, 21 Jul 2022 10:45:03 +0200 Subject: [PATCH] Simplify the selection for dynamic thread pool impl - If on window use native OS APIs (libdispatch isn't available anyways). - If on linux use the superior custom implementation unless the user explicitly requests libdispatch (which is incompatible with gcc). - Otherwise require libdispatch. --- CMakeLists.txt | 3 +-- .../detail/impl/dynamic_thread_pool_group.ipp | 24 +++++-------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25bdc34b6..134156bbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,10 +349,9 @@ else() check_have_libdispatch(WITH_LIBDISPATCH dispatch) if(LLFIO_HAS_LIBDISPATCH_WITH_LIBDISPATCH) all_link_libraries(PUBLIC dispatch) + all_compile_definitions(PUBLIC LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD=1) endif() endif() - else() - all_compile_definitions(PUBLIC LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD=0) endif() if(NOT LLFIO_HAS_LIBDISPATCH_BUILTIN AND NOT LLFIO_HAS_LIBDISPATCH_WITH_LIBDISPATCH AND (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE)) indented_message(FATAL_ERROR "FATAL: Grand Central Dispatch as libdispatch was not found on this FreeBSD or Mac OS system. libdispatch is required for LLFIO to build on those systems.") diff --git a/include/llfio/v2.0/detail/impl/dynamic_thread_pool_group.ipp b/include/llfio/v2.0/detail/impl/dynamic_thread_pool_group.ipp index 240d59479..71a5096c0 100644 --- a/include/llfio/v2.0/detail/impl/dynamic_thread_pool_group.ipp +++ b/include/llfio/v2.0/detail/impl/dynamic_thread_pool_group.ipp @@ -39,31 +39,19 @@ Distributed under the Boost Software License, Version 1.0. #include -#ifndef LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD -#if LLFIO_FORCE_USE_LIBDISPATCH -#include -#define LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD 1 -#else -#ifdef _WIN32 +#if defined(_WIN32) #include "windows/import.hpp" #include -#else -#if __has_include() -#include -#define LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD 1 -#endif -#endif -#endif -#endif -#if !LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD && !defined(_WIN32) -#if !defined(__linux__) -#error dynamic_thread_pool_group requires Grand Central Dispatch (libdispatch) on non-Linux POSIX. -#endif +#elif defined(__linux__) && !LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD #include /* Defines DT_* constants */ #include #include #include +#elif __has_include() +#include +#else +#error dynamic_thread_pool_group requires Grand Central Dispatch (libdispatch) on non-Linux POSIX. #endif #define LLFIO_DYNAMIC_THREAD_POOL_GROUP_PRINTING 0