Skip to content

Commit 3354ed3

Browse files
authored
Merge pull request #68 from ned14/dynamic_thread_pool_group
Dynamic thread pool group
2 parents 17a1547 + c66ba10 commit 3354ed3

File tree

21 files changed

+4448
-197
lines changed

21 files changed

+4448
-197
lines changed

CMakeLists.txt

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ option(LLFIO_ENABLE_DEPENDENCY_SMOKE_TEST "Whether to build executables which ar
3232
option(LLFIO_ASSUME_CROSS_COMPILING "Whether to assume we are cross compiling. Normally automatically detected, but if automatic detection doesn't work, a working <filesystem> will not be found during cmake configure." OFF)
3333
option(UNIT_TESTS_BUILD_ALL "Whether to run all of the unit test suite." OFF)
3434
set(UNIT_TESTS_CXX_VERSION "latest" CACHE STRING "The version of C++ to use in the header-only unit tests")
35+
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE)
36+
option(LLFIO_USE_LIBDISPATCH "Whether to use libdispatch/Grand Unified Dispatch (defaults on on BSD/Mac OS)" ON)
37+
else()
38+
option(LLFIO_USE_LIBDISPATCH "Whether to use libdispatch/Grand Unified Dispatch (defaults on on BSD/Mac OS)" OFF)
39+
endif()
3540

3641
ensure_git_subrepo("${CMAKE_CURRENT_SOURCE_DIR}/include/llfio/ntkernel-error-category/include" "https://github.com/ned14/ntkernel-error-category.git")
3742

@@ -283,6 +288,30 @@ int main() {
283288
all_compile_definitions(PUBLIC LLFIO_FORCE_EXPERIMENTAL_FILESYSTEM=1 KERNELTEST_FORCE_EXPERIMENTAL_FILESYSTEM=1)
284289
endif()
285290
endif()
291+
# Do we have Grand Central Dispatch on this platform?
292+
if(LLFIO_USE_LIBDISPATCH)
293+
function(check_have_libdispatch postfix)
294+
set(CMAKE_REQUIRED_LIBRARIES ${ARGN})
295+
check_cxx_source_compiles("
296+
#include <dispatch/dispatch.h>
297+
int main() {
298+
return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) != nullptr;
299+
}
300+
" LLFIO_HAS_LIBDISPATCH_${postfix})
301+
endfunction()
302+
check_have_libdispatch(BUILTIN)
303+
if(NOT LLFIO_HAS_LIBDISPATCH_BUILTIN)
304+
check_have_libdispatch(WITH_LIBDISPATCH dispatch)
305+
if(LLFIO_HAS_LIBDISPATCH_WITH_LIBDISPATCH)
306+
all_link_libraries(PUBLIC dispatch)
307+
endif()
308+
endif()
309+
else()
310+
all_compile_definitions(PUBLIC LLFIO_DYNAMIC_THREAD_POOL_GROUP_USING_GCD=0)
311+
endif()
312+
if(NOT LLFIO_HAS_LIBDISPATCH_BUILTIN AND NOT LLFIO_HAS_LIBDISPATCH_WITH_LIBDISPATCH AND (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE))
313+
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.")
314+
endif()
286315

287316
# Set any macros this library requires
288317
all_compile_definitions(PRIVATE LLFIO_INCLUDE_STORAGE_PROFILE=1 LLFIO_ENABLE_TEST_IO_MULTIPLEXERS=1)
@@ -293,7 +322,8 @@ if(LLFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE)
293322
all_compile_definitions(PUBLIC LLFIO_EXPERIMENTAL_STATUS_CODE=1)
294323
endif()
295324
if(WIN32)
296-
all_compile_definitions(PRIVATE _WIN32_WINNT=0x601) ## Target Win7
325+
all_compile_definitions(PRIVATE _WIN32_WINNT=0x601) ## Target Win7
326+
target_compile_definitions(llfio_hl INTERFACE _WIN32_WINNT=0x601) ## Target Win7
297327
if(NOT LLFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE)
298328
target_link_libraries(llfio_hl INTERFACE ntkernel-error-category::hl)
299329
target_link_libraries(llfio_dl PUBLIC ntkernel-error-category::dl)

cmake/headers.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ set(llfio_HEADERS
2929
"include/llfio/v2.0/detail/impl/cached_parent_handle_adapter.ipp"
3030
"include/llfio/v2.0/detail/impl/clone.ipp"
3131
"include/llfio/v2.0/detail/impl/config.ipp"
32+
"include/llfio/v2.0/detail/impl/dynamic_thread_pool_group.ipp"
3233
"include/llfio/v2.0/detail/impl/fast_random_file_handle.ipp"
3334
"include/llfio/v2.0/detail/impl/io_multiplexer.ipp"
3435
"include/llfio/v2.0/detail/impl/path_discovery.ipp"
@@ -77,6 +78,7 @@ set(llfio_HEADERS
7778
"include/llfio/v2.0/detail/impl/windows/test/iocp_multiplexer.ipp"
7879
"include/llfio/v2.0/detail/impl/windows/utils.ipp"
7980
"include/llfio/v2.0/directory_handle.hpp"
81+
"include/llfio/v2.0/dynamic_thread_pool_group.hpp"
8082
"include/llfio/v2.0/fast_random_file_handle.hpp"
8183
"include/llfio/v2.0/file_handle.hpp"
8284
"include/llfio/v2.0/fs_handle.hpp"

cmake/tests.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(llfio_TESTS
77
"test/tests/directory_handle_create_close/runner.cpp"
88
"test/tests/directory_handle_enumerate/kernel_directory_handle_enumerate.cpp.hpp"
99
"test/tests/directory_handle_enumerate/runner.cpp"
10+
"test/tests/dynamic_thread_pool_group.cpp"
1011
"test/tests/fast_random_file_handle.cpp"
1112
"test/tests/file_handle_create_close/kernel_file_handle.cpp.hpp"
1213
"test/tests/file_handle_create_close/runner.cpp"
@@ -28,6 +29,7 @@ set(llfio_TESTS
2829
"test/tests/section_handle_create_close/kernel_section_handle.cpp.hpp"
2930
"test/tests/section_handle_create_close/runner.cpp"
3031
"test/tests/shared_fs_mutex.cpp"
32+
"test/tests/statfs.cpp"
3133
"test/tests/symlink_handle_create_close/kernel_symlink_handle.cpp.hpp"
3234
"test/tests/symlink_handle_create_close/runner.cpp"
3335
"test/tests/traverse.cpp"

include/llfio/revision.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
2-
#define LLFIO_PREVIOUS_COMMIT_REF 545a722a055dcc38e7f80520a7a34008bfa9a86f
3-
#define LLFIO_PREVIOUS_COMMIT_DATE "2021-03-15 10:40:32 +00:00"
4-
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 545a722a
2+
#define LLFIO_PREVIOUS_COMMIT_REF 67226948b9f00aebbf33c232d10c417ba1abb289
3+
#define LLFIO_PREVIOUS_COMMIT_DATE "2021-03-16 12:31:40 +00:00"
4+
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 67226948

0 commit comments

Comments
 (0)