Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task coroutine #44

Merged
merged 50 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
31f5a88
test: fix multiple unsequenced modifications
xlauko Feb 13, 2024
321d70c
cmake: add utils
xlauko Feb 21, 2024
b3f7cba
core: add core library
xlauko Feb 21, 2024
bfb9ed0
cmake: add library packaging utils
xlauko Feb 21, 2024
dd30474
cmake: simplify core library creation
xlauko Feb 21, 2024
7d376e7
coro: setup library
xlauko Feb 21, 2024
36ced88
cmake: integrate coro library
xlauko Feb 21, 2024
c88a48f
treewide: clean up coro dependencies
xlauko Feb 21, 2024
6ec1fed
test: update dependencie to new gap libraries structure
xlauko Feb 21, 2024
d26f8b9
coro: add broken promise exception
xlauko Feb 26, 2024
c895b8b
coro: introduce task coroutine
xlauko Feb 26, 2024
7b0024b
vcpkg: remove obsolete fmt dependency
xlauko Feb 26, 2024
9c68e72
coro: add awaitable traits
xlauko Feb 26, 2024
4b52110
coro: add manual reset event
xlauko Feb 26, 2024
afa4e1c
coro: add sync_wait_task
xlauko Feb 26, 2024
88ac2f7
coro: add sync_wait for tasks
xlauko Feb 26, 2024
4521122
coro: add include to awaitable traits
xlauko Feb 26, 2024
447d423
coro: simplify sync_await
xlauko Feb 26, 2024
94fb712
core: add unwrap reference trait
xlauko Feb 27, 2024
e83e2af
coro: implement coroutine fmap
xlauko Feb 27, 2024
b6e23ae
coro: add single consumer event
xlauko Feb 27, 2024
2c7b599
coro: unify sync wait
xlauko Feb 27, 2024
10b3a39
coro: fix task promise manipulations
xlauko Feb 27, 2024
05088d7
coro: add make_task
xlauko Feb 27, 2024
f16f6f0
coro: add when_all_ready coroutine
xlauko Feb 27, 2024
5147496
test: add task tests
xlauko Feb 27, 2024
7728a25
coro: fix single consumer state_kind declaration
xlauko Feb 27, 2024
a2532d7
coro: add missing include for fmap
xlauko Feb 27, 2024
53a645a
coro: fix noexcept declarations
xlauko Feb 27, 2024
2747cb8
core: remove ambiguous recursive memoize test
xlauko Feb 29, 2024
a3febae
test: remove unsused arg
xlauko Feb 29, 2024
71943f9
coro: update consumer kind enum
xlauko Feb 29, 2024
259e742
gh: bump checkout action
xlauko Mar 1, 2024
af2439c
coro: do not require symmetric transfer
xlauko Mar 1, 2024
d3850c7
coro: fix variable shadowing
xlauko Mar 1, 2024
4dbb0b2
core: add inline helper macros
xlauko Mar 1, 2024
85cb9a5
coro: consider implementation for compilers without symmetric transfe…
xlauko Mar 1, 2024
b3d7a2e
test: fix type deductions
xlauko Mar 1, 2024
5bd95d1
coro: add async_manual_reset_event
xlauko Mar 1, 2024
2a4bade
cmake: make coro static library
xlauko Mar 1, 2024
ee49477
coro: add copyright notice
xlauko Mar 1, 2024
cbb705c
coro: add shared task
xlauko Mar 1, 2024
d524ef3
coro: fix when all references
xlauko Mar 1, 2024
eaba798
test: add when all ready tests
xlauko Mar 1, 2024
687fc6a
test: add cppcoro copyright notices
xlauko Mar 1, 2024
5d92baf
coro: fix awaiter variable shadowing
xlauko Mar 1, 2024
8b71500
core: add on_scope_exit
xlauko Mar 1, 2024
bb3affa
test: extract counted class
xlauko Mar 1, 2024
05d4db6
test: add shared_task tests
xlauko Mar 1, 2024
8490997
test: add sync_wait tests
xlauko Mar 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
timeout-minutes: 15

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true

Expand Down
52 changes: 20 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if(NOT DEFINED GAP_MASTER_PROJECT)
endif()

include(project_settings)
include(utils)

# adds header paths of library to list named var
function(add_headers lib var)
Expand All @@ -44,6 +45,15 @@ function(add_headers lib var)
set(${var} ${headers} PARENT_SCOPE)
endfunction()

# adds source paths of library to list named var
function(add_sources lib var)
set(sources ${${var}})
foreach (source ${ARGN})
set(sources ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/src/${source})
endforeach()
set(${var} ${sources} PARENT_SCOPE)
endfunction()

#
# CCACHE
#
Expand Down Expand Up @@ -91,9 +101,12 @@ endif()
#

add_subdirectory(core)
add_subdirectory(coro)
add_subdirectory(graph)

set(GAP_HEADERS
${GAP_CORE_HEADERS}
${GAP_CORO_HEADERS}
)

add_library(gap INTERFACE)
Expand All @@ -102,6 +115,7 @@ add_library(gap::gap ALIAS gap)
target_link_libraries(gap
INTERFACE
gap-core
gap-coro
gap-settings
)

Expand All @@ -118,15 +132,6 @@ if (GAP_ENABLE_TESTING)
add_subdirectory(test)
endif ()

#
# examples
#
option(GAP_ENABLE_EXAMPLES "Enable GAP Examples Builds" ON)

if (GAP_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif ()

#
# instalation support
#
Expand All @@ -144,31 +149,14 @@ set_target_properties(${PROJECT_NAME}
if (GAP_INSTALL)
set(GAP_CMAKE_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} CACHE PATH "Path where CMake utilities will be installed")

set(GAP_INSTALL_TARGETS gap gap-core gap-settings)
set(GAP_INSTALL_TARGETS gap gap-core gap-coro gap-settings)
set(GAP_EXPORT_NAME gapTargets)

install(TARGETS ${GAP_INSTALL_TARGETS}
EXPORT ${GAP_EXPORT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_SKIP
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gap/core
)

install(EXPORT ${GAP_EXPORT_NAME}
FILE ${GAP_EXPORT_NAME}.cmake
NAMESPACE gap::
DESTINATION ${GAP_CMAKE_INSTALL_DIR}
)

install(TARGETS ${GAP_INSTALL_TARGETS}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_ONLY
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gap/core
)
install_gap_target(gap core)
install_gap_target(gap-core core)
install_gap_target(gap-settings core)
install_gap_target(gap-coro coro)
install_gap_target(gap-graph graph)

#
# packaging support
Expand Down
62 changes: 62 additions & 0 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function(add_gap_library name headers)
add_library(${name} INTERFACE)

add_library(gap::${name} ALIAS ${name})

target_compile_features(${name} INTERFACE cxx_std_20)

target_include_directories(${name}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

set_target_properties(${name} PROPERTIES PUBLIC_HEADER "${headers}")

target_link_libraries(${name} INTERFACE gap-settings)
endfunction()

function(add_gap_static_library name headers sources)
add_library(${name} STATIC ${sources})

add_library(gap::${name} ALIAS ${name})

target_compile_features(${name} INTERFACE cxx_std_20)

target_include_directories(${name}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

set_target_properties(${name} PROPERTIES PUBLIC_HEADER "${headers}")

target_link_libraries(${name} INTERFACE gap-settings)
endfunction()

function(install_gap_target name include_dir)
set(GAP_EXPORT_NAME gapTargets)

install(TARGETS ${name}
EXPORT ${GAP_EXPORT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_SKIP
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gap/${include_dir}
)

install(EXPORT ${GAP_EXPORT_NAME}
FILE ${GAP_EXPORT_NAME}.cmake
NAMESPACE gap::
DESTINATION ${GAP_CMAKE_INSTALL_DIR}
)

install(TARGETS ${name}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_ONLY
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gap/${include_dir}
)
endfunction()
16 changes: 1 addition & 15 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,4 @@ add_headers(core GAP_CORE_HEADERS
union_find.hpp
)

add_library(gap-core INTERFACE)

add_library(gap::gap-core ALIAS gap-core)

target_compile_features(gap-core INTERFACE cxx_std_20)

target_include_directories(gap-core
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

set_target_properties(gap-core PROPERTIES PUBLIC_HEADER "${GAP_CORE_HEADERS}")

target_link_libraries(gap-core INTERFACE gap-settings)
add_gap_library(gap-core "${GAP_CORE_HEADERS}")
14 changes: 14 additions & 0 deletions core/include/gap/core/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,17 @@
#define GAP_COROHEADER_FOUND_AND_USABLE
#endif
#endif

#if GAP_COMPILER_MSVC
# define GAP_NOINLINE __declspec(noinline)
#elif GAP_COMPILER_CLANG || GAP_COMPILER_GCC
# define GAP_NOINLINE __attribute__((noinline))
#endif

#if GAP_COMPILER_MSVC
# define GAP_FORCE_INLINE __forceinline
#elif GAP_COMPILER_CLANG
# define GAP_FORCE_INLINE __attribute__((always_inline))
#else
# define GAP_FORCE_INLINE inline
#endif
40 changes: 2 additions & 38 deletions core/include/gap/core/coroutine.hpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
// Copyright (c) 2021-present, Trail of Bits, Inc.
// Copyright (c) 2024, Trail of Bits, Inc.

#pragma once

#ifdef GAP_ENABLE_COROUTINES

#include "gap/core/config.hpp"

#ifdef GAP_COROHEADER_FOUND_AND_USABLE

#include <coroutine>

namespace gap
{
using std::coroutine_handle;
using std::noop_coroutine;
using std::suspend_always;
using std::suspend_never;

} // namespace gap

#elif __has_include(<experimental/coroutine>)

#include <experimental/coroutine>

namespace gap
{
using std::experimental::coroutine_handle;
using std::experimental::suspend_always;
using std::experimental::suspend_never;

#if GAP_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER
using std::experimental::noop_coroutine;
#endif
} // namespace gap

#else
#error gap requires a C++20 compiler with coroutine support
#endif

#endif
#error "The gap/core/coroutine.hpp header was deprecated and removed. Please update your include paths to use gap/coro/coroutine.hpp instead."
Loading
Loading