diff options
author | Henrik S. Gaßmann <henrik.gassmann@adesso.de> | 2022-07-21 11:45:03 +0300 |
---|---|---|
committer | Henrik S. Gaßmann <henrik.gassmann@adesso.de> | 2022-07-21 13:00:43 +0300 |
commit | a83851bd05393ce0150923fc20899cf1a6ca33a6 (patch) | |
tree | 94158fcc302ee25c4dd8c6f3f4af67769d36cb6f | |
parent | 28ed4621f3233fbfd24d437519f3503d06dba3e0 (diff) |
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.
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/dynamic_thread_pool_group.ipp | 24 |
2 files changed, 7 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 25bdc34b..134156bb 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 240d5947..71a5096c 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 <iostream> -#ifndef LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD -#if LLFIO_FORCE_USE_LIBDISPATCH -#include <dispatch/dispatch.h> -#define LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD 1 -#else -#ifdef _WIN32 +#if defined(_WIN32) #include "windows/import.hpp" #include <threadpoolapiset.h> -#else -#if __has_include(<dispatch/dispatch.h>) -#include <dispatch/dispatch.h> -#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 <dirent.h> /* Defines DT_* constants */ #include <sys/syscall.h> #include <condition_variable> #include <thread> +#elif __has_include(<dispatch/dispatch.h>) +#include <dispatch/dispatch.h> +#else +#error dynamic_thread_pool_group requires Grand Central Dispatch (libdispatch) on non-Linux POSIX. #endif #define LLFIO_DYNAMIC_THREAD_POOL_GROUP_PRINTING 0 |