kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_sync_wait.cpp
Go to the documentation of this file.
3
5
11
23
25
26using namespace Kokkos::utils::callbacks;
27
39
44>());
45
47TEST_F(SyncWaitTest, sync_wait) {
48 const context_t esc{exec};
49
50 auto sndr = stdexec::schedule(esc.get_scheduler());
51
52 ASSERT_THAT(
53 recorder_listener_t::record([sndr = std::move(sndr)]() mutable { // NOLINT(performance-move-const-arg)
54 const auto value = stdexec::sync_wait(std::move(sndr)); // NOLINT(performance-move-const-arg)
55 static_assert(std::same_as<decltype(value), const std::optional<std::tuple<>>>);
56 ASSERT_TRUE(value.has_value());
57 }),
58 testing::IsEmpty());
59}
60
62TEST_F(SyncWaitTest, rethrows) {
63 const context_t esc{exec};
64
65 auto sndr = stdexec::schedule(esc.get_scheduler()) | stdexec::then(Tests::Utils::Functors::ThrowsWhenCopied{});
66
67 ASSERT_THAT(
68 Tests::Utils::Functors::MutableMoveToSyncWait{.sndr = std::move(sndr)},
69 testing::ThrowsMessage<std::runtime_error>(testing::StrEq("ThrowsWhenCopied: Throwing in copy constructor!")));
70}
71
72} // namespace Tests::ExecutionSpaceImpl
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
consteval bool check_nothrow_apply_sender()
Matcher to filter out events that are just noise for tests.
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Definition event.hpp:54
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Definition event.hpp:75
decltype(stdexec::schedule(std::declval< scheduler_t >())) schedule_sender_t
Definition context.hpp:29
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
Definition context.hpp:27
This helper struct throws when copy constructed.