Skip to content
Merged
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
41 changes: 24 additions & 17 deletions example/awaitable-sender/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,27 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(execution)

file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS *.cpp *.hpp
CMakeLists.txt
Jamfile)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES ${PFILES})

add_executable(capy_example_awaitable_sender ${PFILES})

set_property(TARGET capy_example_awaitable_sender
PROPERTY FOLDER "examples")

target_compile_features(capy_example_awaitable_sender
PRIVATE cxx_std_23)

target_link_libraries(capy_example_awaitable_sender
Boost::capy
beman::execution_headers)
add_executable(capy_example_awaitable_sender
awaitable_sender.cpp
awaitable_sender.hpp
awaitable_sender_base.hpp
awaitable_sender_detail.hpp
read_op.hpp)

add_executable(capy_example_awaitable_sender_test
tests.cpp
awaitable_sender.hpp
awaitable_sender_base.hpp
awaitable_sender_detail.hpp
read_op.hpp)

foreach(tgt capy_example_awaitable_sender capy_example_awaitable_sender_test)
set_property(TARGET ${tgt} PROPERTY FOLDER "examples")
target_compile_features(${tgt} PRIVATE cxx_std_23)
target_link_libraries(${tgt}
Boost::capy
beman::execution_headers)
endforeach()

add_test(NAME capy_example_awaitable_sender_test
COMMAND capy_example_awaitable_sender_test)
24 changes: 24 additions & 0 deletions example/awaitable-sender/awaitable_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//

#include "awaitable_sender.hpp"
#include "awaitable_sender_base.hpp"
#include "read_op.hpp"

#include <boost/capy.hpp>

Expand Down Expand Up @@ -180,6 +182,28 @@ int main()
done4.wait();
std::cout << " split_ec error test done\n";

// A native awaitable-sender: read_op derives
// awaitable_sender_base, no as_sender() wrapping.
std::cout << "\n--- native awaitable-sender test ---\n";
std::latch done5(1);

auto rop = capy::read_op::result({}, 42);
auto op5 = ex::connect(
ex::then(
std::move(rop),
[](std::size_t n)
{
std::cout
<< " read " << n << " bytes\n";
}),
demo_receiver{
{pool_ex, std::stop_token{}},
&done5});

ex::start(op5);
done5.wait();
std::cout << " native awaitable-sender test done\n";

// All demos have drained; safe to join the waker thread now.
waker_thread.join();
}
Loading
Loading