Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// include/beman/execution/detail/get_forward_progress_guarantee.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_GET_FORWARD_PROGRESS_GUARANTEE
#define INCLUDED_BEMAN_EXECUTION_DETAIL_GET_FORWARD_PROGRESS_GUARANTEE

#include <beman/execution/detail/common.hpp>
#include <beman/execution/detail/suppress_push.hpp>
#ifdef BEMAN_HAS_IMPORT_STD
import std;
#else
#include <concepts>
#endif
#ifdef BEMAN_HAS_MODULES
import beman.execution.detail.forwarding_query;
#else
#include <beman/execution/detail/forwarding_query.hpp>
#endif

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

namespace beman::execution {

enum class forward_progress_guarantee { concurrent, parallel, weakly_parallel };

struct get_forward_progress_guarantee_t {
template <typename Object>
requires requires(const Object& object, const get_forward_progress_guarantee_t& tag) { object.query(tag); }
auto operator()(const Object& object) const noexcept -> forward_progress_guarantee {
static_assert(::std::same_as<decltype(object.query(*this)), forward_progress_guarantee>);
return object.query(*this);
}

template <typename Object>
auto operator()(const Object&) const noexcept -> forward_progress_guarantee {
return forward_progress_guarantee::weakly_parallel;
}

static constexpr auto query(const ::beman::execution::forwarding_query_t&) noexcept -> bool { return true; }
};

inline constexpr get_forward_progress_guarantee_t get_forward_progress_guarantee{};
} // namespace beman::execution

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

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

#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_GET_FORWARD_PROGRESS_GUARANTEE
7 changes: 7 additions & 0 deletions include/beman/execution/detail/run_loop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import beman.execution.detail.completion_signatures;
import beman.execution.detail.env;
import beman.execution.detail.get_completion_scheduler;
import beman.execution.detail.get_env;
import beman.execution.detail.get_forward_progress_guarantee;
import beman.execution.detail.get_stop_token;
import beman.execution.detail.immovable;
import beman.execution.detail.operation_state;
Expand All @@ -32,6 +33,7 @@ import beman.execution.detail.unstoppable_token;
#include <beman/execution/detail/completion_signatures.hpp>
#include <beman/execution/detail/get_completion_scheduler.hpp>
#include <beman/execution/detail/get_env.hpp>
#include <beman/execution/detail/get_forward_progress_guarantee.hpp>
#include <beman/execution/detail/get_stop_token.hpp>
#include <beman/execution/detail/immovable.hpp>
#include <beman/execution/detail/operation_state.hpp>
Expand Down Expand Up @@ -113,6 +115,11 @@ class run_loop {

auto schedule() noexcept -> sender { return {this->loop}; }
auto operator==(const scheduler&) const -> bool = default;

static constexpr auto query(::beman::execution::get_forward_progress_guarantee_t) noexcept
-> ::beman::execution::forward_progress_guarantee {
return ::beman::execution::forward_progress_guarantee::parallel;
}
};

enum class state : unsigned char { starting, running, finishing };
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 @@ -89,6 +89,7 @@ target_sources(
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_domain_early.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_domain_late.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_env.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_forward_progress_guarantee.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_scheduler.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/get_stop_token.hpp
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/has_as_awaitable.hpp
Expand Down Expand Up @@ -275,6 +276,7 @@ if(BEMAN_USE_MODULES)
get_domain_late.cppm
get_domain.cppm
get_env.cppm
get_forward_progress_guarantee.cppm
get_scheduler.cppm
get_stop_token.cppm
has_as_awaitable.cppm
Expand Down
7 changes: 4 additions & 3 deletions src/beman/execution/execution.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export import beman.execution.detail.get_completion_signatures; // [exec.getcomp
import beman.execution.detail.get_delegation_scheduler;
import beman.execution.detail.get_domain;
import beman.execution.detail.get_env;
import beman.execution.detail.get_forward_progress_guarantee;
import beman.execution.detail.get_scheduler;
import beman.execution.detail.get_stop_token;
export import beman.execution.detail.inplace_stop_source; // [stopsource.inplace], class inplace_stop_source
Expand Down Expand Up @@ -133,14 +134,14 @@ export using ::beman::execution::get_domain_t;
export using ::beman::execution::get_scheduler_t;
export using ::beman::execution::get_delegation_scheduler_t;
export using ::beman::execution::get_await_completion_adaptor_t;
//-dk:TODO export using ::beman::execution::get_forward_progress_guarantee_t;
export using ::beman::execution::get_forward_progress_guarantee_t;

export using ::beman::execution::get_domain;
export using ::beman::execution::get_scheduler;
export using ::beman::execution::get_delegation_scheduler;
export using ::beman::execution::get_await_completion_adaptor;
//-dk:TODO export using ::beman::execution::forward_progress_guarantee;
//-dk:TODO export using ::beman::execution::get_forward_progress_guarantee;
export using ::beman::execution::forward_progress_guarantee;
export using ::beman::execution::get_forward_progress_guarantee;

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

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

export module beman.execution.detail.get_forward_progress_guarantee;

namespace beman::execution {
export using beman::execution::forward_progress_guarantee;
export using beman::execution::get_forward_progress_guarantee_t;
export using beman::execution::get_forward_progress_guarantee;
} // namespace beman::execution
3 changes: 3 additions & 0 deletions tests/beman/execution/exec-run-loop-general.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ TEST(exec_run_loop_general) {
});
static_assert(requires { rl.run(); });
static_assert(requires { rl.finish(); });

ASSERT(test_std::get_forward_progress_guarantee(rl.get_scheduler()) ==
test_std::forward_progress_guarantee::parallel);
}
Loading