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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ CMakeUserPresets.json
*.app

build
cmake-build-*
.DS_store
.vs
.cache
Expand Down
79 changes: 79 additions & 0 deletions include/beman/execution/detail/inline_scheduler.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// include/beman/execution/detail/inline_scheduler.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef INCLUDED_BEMAN_DETAIL_EXECUTION_INLINE_SCHEDULER
#define INCLUDED_BEMAN_DETAIL_EXECUTION_INLINE_SCHEDULER

// ----------------------------------------------------------------------------
#include <beman/execution/detail/common.hpp>
#ifdef BEMAN_HAS_IMPORT_STD
import std;
#else
#include <type_traits>
#include <utility>
#endif
#ifdef BEMAN_HAS_MODULES
import beman.execution.detail.get_completion_scheduler;
import beman.execution.detail.sender;
import beman.execution.detail.receiver;
import beman.execution.detail.set_value;
import beman.execution.detail.operation_state;
import beman.execution.detail.scheduler;
import beman.execution.detail.scheduler_t;
import beman.execution.detail.completion_signatures;
#else
#include <beman/execution/detail/get_completion_scheduler.hpp>
#include <beman/execution/detail/sender.hpp>
#include <beman/execution/detail/receiver.hpp>
#include <beman/execution/detail/set_value.hpp>
#include <beman/execution/detail/operation_state.hpp>
#include <beman/execution/detail/scheduler.hpp>
#include <beman/execution/detail/completion_signatures.hpp>
#endif

namespace beman::execution {
struct inline_scheduler {
using scheduler_concept = ::beman::execution::scheduler_t;

struct env {
static auto
query(const ::beman::execution::get_completion_scheduler_t<::beman::execution::set_value_t>&) noexcept
-> inline_scheduler {
return {};
}
};

template <::beman::execution::receiver Rcvr>
struct state {
using operation_state_concept = ::beman::execution::operation_state_t;
::std::remove_cvref_t<Rcvr> rcvr;
auto start() & noexcept -> void { ::beman::execution::set_value(::std::move(rcvr)); }
};

struct sender {
using sender_concept = ::beman::execution::sender_t;
using completion_signatures = ::beman::execution::completion_signatures<::beman::execution::set_value_t()>;

static constexpr auto get_env() noexcept -> env { return {}; }

template <typename, typename...>
static consteval auto get_completion_signatures() noexcept -> completion_signatures {
return {};
}

template <::beman::execution::receiver Rcvr>
auto connect(Rcvr&& receiver) noexcept(::std::is_nothrow_constructible_v<::std::remove_cvref_t<Rcvr>, Rcvr>)
-> state<Rcvr> {
return {::std::forward<Rcvr>(receiver)};
}
};

static constexpr auto schedule() noexcept -> sender { return {}; }

auto operator==(const inline_scheduler&) const -> bool = default;
};
} // namespace beman::execution

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

#endif // INCLUDED_BEMAN_DETAIL_EXECUTION_INLINE_SCHEDULER
2 changes: 2 additions & 0 deletions src/beman/execution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ target_sources(
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/impls_for.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/indices_for.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/indirect_meta_apply.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/inline_scheduler.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/inplace_stop_source.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/into_variant.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/intrusive_stack.hpp
Expand Down Expand Up @@ -282,6 +283,7 @@ if(BEMAN_USE_MODULES)
impls_for.cppm
indices_for.cppm
indirect_meta_apply.cppm
inline_scheduler.cppm
inplace_stop_source.cppm
into_variant.cppm
intrusive_stack.cppm
Expand Down
4 changes: 4 additions & 0 deletions src/beman/execution/execution.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import beman.execution.detail.when_all;
import beman.execution.detail.when_all_with_variant;
export import beman.execution.detail.with_awaitable_senders; // [exec.with.awaitable.senders]
import beman.execution.detail.write_env;
import beman.execution.detail.inline_scheduler;

// [stoptoken.concepts], stop token concepts
export import beman.execution.detail.stoppable_token;
Expand Down Expand Up @@ -254,6 +255,9 @@ export using ::beman::execution::counting_scope;
export using ::beman::execution::spawn;
export using ::beman::execution::spawn_future;

// [exec.inline.scheduler]
export using ::beman::execution::inline_scheduler;

#if 0
namespace detail {
export using ::beman::execution::detail::await_result_type;
Expand Down
11 changes: 11 additions & 0 deletions src/beman/execution/inline_scheduler.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module;
// src/beman/execution/inline_scheduler.cppm -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

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

export module beman.execution.detail.inline_scheduler;

namespace beman::execution {
export using beman::execution::inline_scheduler;
} // namespace beman::execution
4 changes: 2 additions & 2 deletions tests/beman/execution/exec-scope-counting.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <concepts>
#include <tuple>
#include <type_traits>
#include <test/inline_scheduler.hpp>
#include <test/execution.hpp>
#ifdef BEMAN_HAS_MODULES
import beman.execution;
Expand All @@ -13,6 +12,7 @@ import beman.execution;
#include <beman/execution/detail/sender.hpp>
#include <beman/execution/detail/just.hpp>
#include <beman/execution/detail/sync_wait.hpp>
#include <beman/execution/detail/inline_scheduler.hpp>
#endif

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -45,7 +45,7 @@ struct join_receiver {
using receiver_concept = test_std::receiver_t;

struct env {
auto query(const test_std::get_scheduler_t&) const noexcept -> test::inline_scheduler { return {}; }
auto query(const test_std::get_scheduler_t&) const noexcept -> test_std::inline_scheduler { return {}; }
};

bool& called;
Expand Down
4 changes: 2 additions & 2 deletions tests/beman/execution/exec-scope-simple-counting.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <concepts>
#include <tuple>
#include <type_traits>
#include <test/inline_scheduler.hpp>
#include <test/execution.hpp>
#ifdef BEMAN_HAS_MODULES
import beman.execution;
Expand All @@ -13,6 +12,7 @@ import beman.execution;
#include <beman/execution/detail/sender.hpp>
#include <beman/execution/detail/just.hpp>
#include <beman/execution/detail/sync_wait.hpp>
#include <beman/execution/detail/inline_scheduler.hpp>
#endif

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -42,7 +42,7 @@ struct join_receiver {
using receiver_concept = test_std::receiver_t;

struct env {
auto query(const test_std::get_scheduler_t&) const noexcept -> test::inline_scheduler { return {}; }
auto query(const test_std::get_scheduler_t&) const noexcept -> test_std::inline_scheduler { return {}; }
};

bool& called;
Expand Down
56 changes: 0 additions & 56 deletions tests/beman/execution/include/test/inline_scheduler.hpp

This file was deleted.