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
43 changes: 43 additions & 0 deletions include/beman/execution/detail/sender_to.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// include/beman/execution/detail/sender_to.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_SENDER_TO
#define INCLUDED_BEMAN_EXECUTION_DETAIL_SENDER_TO

#ifdef BEMAN_HAS_IMPORT_STD
import std;
#else
#include <utility>
#endif
#include <beman/execution/detail/common.hpp>
#ifdef BEMAN_HAS_MODULES
import beman.execution.detail.completion_signatures_of_t;
import beman.execution.detail.connect;
import beman.execution.detail.env_of_t;
import beman.execution.detail.receiver_of;
import beman.execution.detail.sender_in;
#else
#include <beman/execution/detail/completion_signatures_of_t.hpp>
#include <beman/execution/detail/connect.hpp>
#include <beman/execution/detail/env_of_t.hpp>
#include <beman/execution/detail/receiver_of.hpp>
#include <beman/execution/detail/sender_in.hpp>
#endif

// ----------------------------------------------------------------------------

namespace beman::execution {
template <typename Sender, typename Receiver>
concept sender_to =
::beman::execution::sender_in<Sender, ::beman::execution::env_of_t<Receiver>> &&
::beman::execution::receiver_of<
Receiver,
::beman::execution::completion_signatures_of_t<Sender, ::beman::execution::env_of_t<Receiver>>> &&
requires(Sender&& sndr, Receiver&& rcvr) {
::beman::execution::connect(::std::forward<Sender>(sndr), ::std::forward<Receiver>(rcvr));
};
} // namespace beman::execution

// ----------------------------------------------------------------------------

#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_SENDER_TO
2 changes: 2 additions & 0 deletions include/beman/execution/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import beman.execution.detail.write_env;
#include <beman/execution/detail/get_env.hpp>
#include <beman/execution/detail/get_scheduler.hpp>
#include <beman/execution/detail/get_stop_token.hpp>
#include <beman/execution/detail/inline_scheduler.hpp>
#include <beman/execution/detail/into_variant.hpp>
#include <beman/execution/detail/just.hpp>
#include <beman/execution/detail/let.hpp>
Expand All @@ -102,6 +103,7 @@ import beman.execution.detail.write_env;
#include <beman/execution/detail/scope_token.hpp>
#include <beman/execution/detail/sender_adaptor_closure.hpp>
#include <beman/execution/detail/sender_in.hpp>
#include <beman/execution/detail/sender_to.hpp>
#include <beman/execution/detail/sender.hpp>
#include <beman/execution/detail/set_error.hpp>
#include <beman/execution/detail/set_stopped.hpp>
Expand Down
2 changes: 2 additions & 0 deletions src/beman/execution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ target_sources(
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sender_for.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sender_has_affine_on.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sender_in.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sender_to.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/sends_stopped.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/set_error.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/set_stopped.hpp
Expand Down Expand Up @@ -345,6 +346,7 @@ if(BEMAN_USE_MODULES)
sender_has_affine_on.cppm
sender_in.cppm
sender.cppm
sender_to.cppm
sends_stopped.cppm
set_error.cppm
set_stopped.cppm
Expand Down
1 change: 1 addition & 0 deletions src/beman/execution/execution.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export import beman.execution.detail.receiver_of;
export import beman.execution.detail.sender;
export import beman.execution.detail.sender_in;
//-dk:TODO export using ::beman::execution::sender_to;
export import beman.execution.detail.sender_to;

export import beman.execution.detail.sends_stopped;

Expand Down
11 changes: 11 additions & 0 deletions src/beman/execution/sender_to.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module;
// src/beman/execution/sender_to.cppm -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/execution/detail/sender_to.hpp>

export module beman.execution.detail.sender_to;

namespace beman::execution {
export using beman::execution::sender_to;
} // namespace beman::execution
12 changes: 12 additions & 0 deletions tests/beman/execution/exec-snd-concepts.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ auto test_sender_for() -> void {
static_assert(test_std::sender<std_sender>);
static_assert(not test_detail::sender_for<std_sender, tag_t>);
}

auto test_sender_to() -> void {
struct int_receiver {
using receiver_concept = test_std::receiver_t;
static auto set_value(int) noexcept -> void {}
};

static_assert(test_std::sender_to<decltype(test_std::just(1)), int_receiver>);
static_assert(not test_std::sender_to<decltype(test_std::just()), int_receiver>);
}

} // namespace

TEST(exec_snd_concepts) {
Expand All @@ -183,4 +194,5 @@ TEST(exec_snd_concepts) {
test_sender_in();
test_tag_of_t();
test_sender_for();
test_sender_to();
}
Loading