Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/ci-latest-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
-DBUILD_EXAMPLES=ON \
-DBUILD_BENCHMARKS=ON \
-DBUILD_TESTS=ON \
-DENABLE_STDEXEC=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
-DBUILD_EXAMPLES=ON \
-DBUILD_BENCHMARKS=ON \
-DBUILD_TESTS=ON \
-DENABLE_STDEXEC=ON \
$SANITIZER_FLAG \
-DCMAKE_C_COMPILER=${{matrix.compiler.cc}} \
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-static-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
-DBUILD_EXAMPLES=ON \
-DBUILD_BENCHMARKS=ON \
-DBUILD_TESTS=ON \
-DENABLE_STDEXEC=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Debug \
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
-DBUILD_EXAMPLES=ON \
-DBUILD_BENCHMARKS=ON \
-DBUILD_TESTS=ON \
-DENABLE_STDEXEC=ON \
-DCMAKE_C_COMPILER=${{ matrix.compiler.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} \
-DCMAKE_BUILD_TYPE=Debug
Expand All @@ -61,8 +62,10 @@ jobs:
- name: Build module-hello
# liburing < 2.13 exposes TU-local entities that break GCC modules
# https://github.com/axboe/liburing/issues/1457
# stdexec uses TU-local entities incompatible with GCC C++20 modules
if: >
matrix.generator == 'Ninja'
&& matrix.compiler.cc != 'gcc'
&& !(matrix.compiler.cc == 'gcc' && matrix.liburing-version == '2.3')
run: |
cmake -B ${{github.workspace}}/build_module -G Ninja \
Expand All @@ -75,5 +78,6 @@ jobs:
- name: Run module-hello
if: >
matrix.generator == 'Ninja'
&& matrix.compiler.cc != 'gcc'
&& !(matrix.compiler.cc == 'gcc' && matrix.liburing-version == '2.3')
run: ${{github.workspace}}/build_module/examples/module-hello
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "third_party/doxygen-awesome-css"]
path = third_party/doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "third_party/stdexec"]
path = third_party/stdexec
url = https://github.com/NVIDIA/stdexec.git
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ option(TESTS_STATIC_LINK "Use static linking for tests" OFF)
option(TESTS_TSAN "Enable thread sanitizer for tests" OFF)
option(TESTS_ASAN "Enable address and undefined behavior sanitizers for tests" OFF)
option(LINK_LIBURING "Use liburing from third_party and link it to condy" ON)
option(ENABLE_STDEXEC "Enable stdexec execution integration" ON)

if (ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
Expand Down Expand Up @@ -55,6 +56,12 @@ if(BUILD_EXAMPLES OR BUILD_BENCHMARKS OR BUILD_TESTS OR LINK_LIBURING OR BUILD_M
set_target_properties(uring PROPERTIES IMPORTED_LOCATION ${LIBURING_SOURCE_DIR}/src/liburing.a)
target_include_directories(uring INTERFACE ${LIBURING_SOURCE_DIR}/src/include)
add_dependencies(uring liburing_ext)

if(ENABLE_STDEXEC)
# stdexec
add_library(stdexec INTERFACE)
target_include_directories(stdexec SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/stdexec/include)
endif()
endif()

if(LINK_LIBURING)
Expand All @@ -67,6 +74,11 @@ if(BUILD_MODULE)
add_subdirectory(module)
endif()

if(ENABLE_STDEXEC)
target_link_libraries(condy INTERFACE stdexec)
target_compile_definitions(condy INTERFACE CONDY_HAS_STDEXEC)
endif()

# Warnings as errors
add_compile_options(-Wall -Wextra -Werror)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
Expand Down
1 change: 1 addition & 0 deletions include/condy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "condy/channel.hpp" // IWYU pragma: export
#include "condy/coro.hpp" // IWYU pragma: export
#include "condy/cqe_handler.hpp" // IWYU pragma: export
#include "condy/execution.hpp" // IWYU pragma: export
#include "condy/futex.hpp" // IWYU pragma: export
#include "condy/helpers.hpp" // IWYU pragma: export
#include "condy/pmr.hpp" // IWYU pragma: export
Expand Down
38 changes: 29 additions & 9 deletions include/condy/channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <new>
#include <optional>
#include <type_traits>
#ifdef CONDY_HAS_STDEXEC
#include "condy/detail/execution.hpp"
#endif

namespace condy {

Expand Down Expand Up @@ -52,6 +55,11 @@ template <typename T, size_t N = 2> class Channel {

CONDY_DELETE_COPY_MOVE(Channel);

private:
class [[nodiscard]] MovePushSenderImpl;
class [[nodiscard]] CopyPushSenderImpl;
class [[nodiscard]] PopSenderImpl;

public:
/**
* @brief Try to push an item into the channel.
Expand Down Expand Up @@ -111,7 +119,11 @@ template <typename T, size_t N = 2> class Channel {
push_awaiters_.push_back(fake_handle);
}

class [[nodiscard]] MovePushSender;
#ifdef CONDY_HAS_STDEXEC
using MovePushSender = detail::StandardSender<MovePushSenderImpl>;
#else
using MovePushSender = MovePushSenderImpl;
#endif
/**
* @brief Push an item into the channel, awaiting if necessary.
* @param item The item to be pushed into the channel.
Expand All @@ -126,7 +138,11 @@ template <typename T, size_t N = 2> class Channel {
*/
MovePushSender push(T &&item) noexcept { return {*this, std::move(item)}; }

class [[nodiscard]] CopyPushSender;
#ifdef CONDY_HAS_STDEXEC
using CopyPushSender = detail::StandardSender<CopyPushSenderImpl>;
#else
using CopyPushSender = CopyPushSenderImpl;
#endif
/**
* @brief Push an item into the channel, awaiting if necessary.
* @param item The item to be pushed into the channel.
Expand All @@ -140,7 +156,11 @@ template <typename T, size_t N = 2> class Channel {
return {*this, item};
}

class [[nodiscard]] PopSender;
#ifdef CONDY_HAS_STDEXEC
using PopSender = detail::StandardSender<PopSenderImpl>;
#else
using PopSender = PopSenderImpl;
#endif
/**
* @brief Pop an item from the channel, awaiting if necessary.
* @return std::pair<int32_t, T> 0 and the popped item if successful; -EPIPE
Expand Down Expand Up @@ -529,12 +549,12 @@ class Channel<T, N>::PopFinishHandle
std::optional<StopCallbackType> stop_callback_;
};

template <typename T, size_t N> class Channel<T, N>::MovePushSender {
template <typename T, size_t N> class Channel<T, N>::MovePushSenderImpl {
public:
using CondySender = void;
using ReturnType = int32_t;

MovePushSender(Channel &channel, T &&item)
MovePushSenderImpl(Channel &channel, T &&item)
: channel_(channel), item_(std::move(item)) {}

template <typename Receiver> auto connect_impl(Receiver receiver) noexcept {
Expand Down Expand Up @@ -562,12 +582,12 @@ template <typename T, size_t N> class Channel<T, N>::MovePushSender {
T &&item_;
};

template <typename T, size_t N> class Channel<T, N>::CopyPushSender {
template <typename T, size_t N> class Channel<T, N>::CopyPushSenderImpl {
public:
using CondySender = void;
using ReturnType = int32_t;

CopyPushSender(Channel &channel, const T &item)
CopyPushSenderImpl(Channel &channel, const T &item)
: channel_(channel), item_(item) {}

template <typename Receiver> auto connect_impl(Receiver receiver) noexcept {
Expand Down Expand Up @@ -598,12 +618,12 @@ template <typename T, size_t N> class Channel<T, N>::CopyPushSender {
const T &item_;
};

template <typename T, size_t N> class Channel<T, N>::PopSender {
template <typename T, size_t N> class Channel<T, N>::PopSenderImpl {
public:
using CondySender = void;
using ReturnType = std::pair<int32_t, T>;

PopSender(Channel &channel) : channel_(channel) {}
PopSenderImpl(Channel &channel) : channel_(channel) {}

template <typename Receiver> auto connect_impl(Receiver receiver) noexcept {
return OperationState<Receiver>(channel_, std::move(receiver));
Expand Down
Loading
Loading