Skip to content

Commit 71c0c8e

Browse files
committed
restored tests and fixed a few minor details
1 parent 124dbec commit 71c0c8e

File tree

13 files changed

+99
-87
lines changed

13 files changed

+99
-87
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ option(
1717
"Enable building tests and test infrastructure. Default: ON. Values: { ON, OFF }."
1818
${PROJECT_IS_TOP_LEVEL}
1919
)
20-
set(BEMAN_TASK_BUILD_TESTS FALSE)
2120

2221
# [CMAKE.SKIP_EXAMPLES]
2322
option(

examples/co_await-task.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,16 @@ namespace ex = beman::execution;
99

1010
// ----------------------------------------------------------------------------
1111

12-
auto inner() -> ex::task<> {
13-
beman::task::detail::logger log("inner");
14-
co_return;
15-
}
12+
auto inner() -> ex::task<> { co_return; }
1613

1714
auto outer() -> ex::task<> {
18-
beman::task::detail::logger log("outer");
1915
for (int i{}; i < 10; ++i) {
2016
co_await inner();
21-
log.log("inner_awaited");
2217
}
2318
co_return;
2419
}
2520

2621
auto main() -> int {
2722
std::cout << std::unitbuf;
28-
beman::task::detail::logger log("sync_wait");
2923
ex::sync_wait(outer());
3024
}

include/beman/task/detail/awaiter.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,17 @@ class awaiter : public ::beman::task::detail::state_base<Value, Env> {
2222
constexpr auto await_ready() const noexcept -> bool { return false; }
2323
template <typename PP>
2424
auto await_suspend(::std::coroutine_handle<PP> parent) noexcept {
25-
::beman::task::detail::logger log("awaiter::suspend");
2625
this->scheduler.emplace(
2726
this->template from_env<scheduler_type>(::beman::execution::get_env(parent.promise())));
2827
this->parent = ::std::move(parent);
2928
assert(this->parent);
3029
return this->handle.start(this);
3130
}
32-
auto await_resume() {
33-
::beman::task::detail::logger l("awaiter::await_resume()");
34-
return this->result_resume();
35-
}
31+
auto await_resume() { return this->result_resume(); }
3632
auto parent_handle() -> ::std::coroutine_handle<> { return ::std::move(this->parent); }
3733

3834
private:
3935
auto do_complete() -> std::coroutine_handle<> override {
40-
::beman::task::detail::logger l("awaiter::complete()");
4136
assert(this->parent);
4237
return ::std::move(this->parent);
4338
}

include/beman/task/detail/final_awaiter.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#define INCLUDED_INCLUDE_BEMAN_TASK_DETAIL_FINAL_AWAITER
66

77
#include <beman/task/detail/state_base.hpp>
8-
#include <beman/task/detail/logger.hpp>
98
#include <coroutine>
109

1110
// ----------------------------------------------------------------------------
@@ -16,7 +15,6 @@ struct final_awaiter {
1615
static constexpr auto await_ready() noexcept -> bool { return false; }
1716
template <typename Promise>
1817
static auto await_suspend(std::coroutine_handle<Promise> handle) noexcept {
19-
::beman::task::detail::logger l("final_awaiter::await_suspend");
2018
return handle.promise().notify_complete();
2119
}
2220
static constexpr void await_resume() noexcept {}

include/beman/task/detail/handle.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#define INCLUDED_INCLUDE_BEMAN_TASK_DETAIL_HANDLE
66

77
#include <beman/execution/execution.hpp>
8-
#include <beman/task/detail/logger.hpp>
98
#include <coroutine>
109
#include <memory>
1110
#include <utility>
@@ -28,7 +27,6 @@ class handle {
2827
auto reset() -> void { this->h.reset(); }
2928
template <typename... A>
3029
auto start(A&&... a) noexcept -> auto {
31-
::beman::task::detail::logger l("handle::start");
3230
return this->h->start(::std::forward<A>(a)...);
3331
}
3432
auto release() -> ::std::coroutine_handle<P> {

include/beman/task/detail/promise_base.hpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#define INCLUDED_INCLUDE_BEMAN_TASK_DETAIL_PROMISE_BASE
66

77
#include <beman/task/detail/state_base.hpp>
8-
#include <beman/task/detail/logger.hpp>
98
#include <beman/execution/execution.hpp>
109
#include <cstddef>
1110
#include <concepts>
@@ -29,11 +28,10 @@ class promise_base {
2928
*/
3029
template <typename T>
3130
void return_value(T&& value) {
32-
::beman::task::detail::logger l("promise_base::return_value(T&&)");
3331
this->get_state()->set_value(::std::forward<T>(value));
3432
}
3533

36-
protected:
34+
public:
3735
auto set_state(::beman::task::detail::state_base<Value, Environment>* s) noexcept -> void { this->state_ = s; }
3836
auto get_state() const noexcept -> ::beman::task::detail::state_base<Value, Environment>* { return this->state_; }
3937

@@ -47,12 +45,9 @@ class promise_base<Stop, void, Environment> {
4745
/*
4846
* \brief Set the value result although without any value.
4947
*/
50-
void return_void() {
51-
::beman::task::detail::logger l("promise_base::return_void()");
52-
this->get_state()->set_value(void_type{});
53-
}
48+
void return_void() { this->get_state()->set_value(void_type{}); }
5449

55-
protected:
50+
public:
5651
auto set_state(::beman::task::detail::state_base<void, Environment>* s) noexcept -> void { this->state_ = s; }
5752
auto get_state() const noexcept -> ::beman::task::detail::state_base<void, Environment>* { return this->state_; }
5853

include/beman/task/detail/promise_type.hpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <coroutine>
2727
#include <optional>
2828
#include <type_traits>
29-
#include <beman/task/detail/logger.hpp>
3029

3130
// ----------------------------------------------------------------------------
3231

@@ -46,14 +45,8 @@ class promise_type
4645
template <typename... A>
4746
promise_type(const A&... a) : allocator(::beman::task::detail::find_allocator<allocator_type>(a...)) {}
4847

49-
constexpr auto initial_suspend() noexcept -> ::std::suspend_always {
50-
::beman::task::detail::logger l("promise_type::initial_suspend");
51-
return {};
52-
}
53-
constexpr auto final_suspend() noexcept -> ::beman::task::detail::final_awaiter {
54-
::beman::task::detail::logger l("promise_type::final_suspend");
55-
return {};
56-
}
48+
constexpr auto initial_suspend() noexcept -> ::std::suspend_always { return {}; }
49+
constexpr auto final_suspend() noexcept -> ::beman::task::detail::final_awaiter { return {}; }
5750

5851
auto unhandled_exception() noexcept { /*-dk:TODO*/ }
5952
std::coroutine_handle<> unhandled_stopped() {
@@ -65,15 +58,11 @@ class promise_type
6558

6659
template <::beman::execution::sender Sender>
6760
auto await_transform(Sender&& sender) noexcept {
68-
::beman::task::detail::logger l("promise_type::await_transform(sender)");
6961
if constexpr (requires { ::std::forward<Sender>(sender).as_awaitable(); }) {
70-
l.log("using sender.as_awaitable");
7162
return ::std::forward<Sender>(sender).as_awaitable();
7263
} else if constexpr (requires { ::beman::execution::as_awaitable(::std::forward<Sender>(sender), *this); }) {
73-
l.log("using as_awaitable");
7464
return ::beman::execution::as_awaitable(::std::forward<Sender>(sender), *this);
7565
} else {
76-
l.log("using as_awaitable(affine_one(...))");
7766
return ::beman::execution::as_awaitable(
7867
::beman::task::affine_on(::std::forward<Sender>(sender), this->get_scheduler()), *this);
7968
}
@@ -91,7 +80,6 @@ class promise_type
9180
auto get_env() const noexcept -> ::beman::task::detail::promise_env<promise_type> { return {this}; }
9281

9382
auto start(::beman::task::detail::state_base<Value, Environment>* state) -> ::std::coroutine_handle<> {
94-
::beman::task::detail::logger l("promise_type::start");
9583
this->set_state(state);
9684
return ::std::coroutine_handle<promise_type>::from_promise(*this);
9785
}

include/beman/task/detail/result_type.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#define INCLUDED_INCLUDE_BEMAN_TASK_DETAIL_RESULT_TYPE
66

77
#include <beman/task/detail/sub_visit.hpp>
8-
#include <beman/task/detail/logger.hpp>
98
#include <beman/execution/execution.hpp>
109
#include <exception>
1110
#include <utility>
@@ -62,15 +61,13 @@ class result_type<Stop, Value, ::beman::execution::completion_signatures<::beman
6261
*/
6362
template <typename T>
6463
void set_value(T&& value) {
65-
::beman::task::detail::logger l("result_type::set_value(T&&)");
6664
this->result.template emplace<1u>(::std::forward<T>(value));
6765
}
6866
/*
6967
* \brief Set the result for a `set_error` completion.
7068
*/
7169
template <typename E>
7270
void set_error(E&& error) {
73-
::beman::task::detail::logger l("result_type::set_error(E&&)");
7471
this->result.template emplace<2u + find_index<0u, ::std::remove_cvref_t<E>, Error...>()>(
7572
::std::forward<E>(error));
7673
}
@@ -88,7 +85,6 @@ class result_type<Stop, Value, ::beman::execution::completion_signatures<::beman
8885
*/
8986
template <::beman::execution::receiver Receiver>
9087
void result_complete(Receiver&& rcvr) {
91-
::beman::task::detail::logger l("result_type::result_complete(R&&)");
9288
switch (this->result.index()) {
9389
case 0:
9490
if constexpr (Stop == ::beman::task::detail::stoppable::yes)
@@ -111,7 +107,6 @@ class result_type<Stop, Value, ::beman::execution::completion_signatures<::beman
111107
}
112108
}
113109
auto result_resume() {
114-
::beman::task::detail::logger l("result_type::result_resume()");
115110
switch (this->result.index()) {
116111
case 0:
117112
std::terminate(); // should never come here!

include/beman/task/detail/state.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#define INCLUDED_INCLUDE_BEMAN_TASK_DETAIL_STATE
66

77
#include <beman/task/detail/state_base.hpp>
8-
#include <beman/task/detail/logger.hpp>
98
#include <beman/task/detail/promise_type.hpp>
109
#include <beman/task/detail/stop_source.hpp>
1110
#include <type_traits>
@@ -71,12 +70,8 @@ struct state : ::beman::task::detail::state_base<T, C>, ::beman::task::detail::s
7170
std::optional<stop_callback_t> stop_callback;
7271
scheduler_type scheduler;
7372

74-
auto start() & noexcept -> void {
75-
::beman::task::detail::logger l("state::start");
76-
this->handle.start(this).resume();
77-
}
73+
auto start() & noexcept -> void { this->handle.start(this).resume(); }
7874
std::coroutine_handle<> do_complete() override {
79-
::beman::task::detail::logger l("state::do_complete()");
8075
this->result_complete(::std::move(this->receiver));
8176
return std::noop_coroutine();
8277
}

include/beman/task/detail/state_base.hpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <beman/task/detail/scheduler_of.hpp>
99
#include <beman/task/detail/error_types_of.hpp>
1010
#include <beman/task/detail/result_type.hpp>
11-
#include <beman/task/detail/logger.hpp>
1211
#include <coroutine>
1312

1413
// ----------------------------------------------------------------------------
@@ -23,31 +22,29 @@ class state_base : public ::beman::task::detail::result_type<::beman::task::deta
2322
using stop_token_type = decltype(std::declval<stop_source_type>().get_token());
2423
using scheduler_type = ::beman::task::detail::scheduler_of_t<Environment>;
2524

26-
std::coroutine_handle<> complete() { return this->do_complete(); }
27-
stop_token_type get_stop_token() { return this->do_get_stop_token(); }
28-
Environment& get_environment() { return this->do_get_environment(); }
29-
scheduler_type get_scheduler() { return this->do_get_scheduler(); }
30-
scheduler_type set_scheduler(scheduler_type other) { return this->do_set_scheduler(other); }
25+
auto complete() -> std::coroutine_handle<> { return this->do_complete(); }
26+
auto get_stop_token() -> stop_token_type { return this->do_get_stop_token(); }
27+
auto get_environment() -> Environment& { return this->do_get_environment(); }
28+
auto get_scheduler() -> scheduler_type { return this->do_get_scheduler(); }
29+
auto set_scheduler(scheduler_type other) -> scheduler_type { return this->do_set_scheduler(other); }
3130

3231
protected:
3332
template <::beman::execution::scheduler Scheduler, typename Env>
3433
static auto from_env(const Env& env) {
35-
::beman::task::detail::logger l{"state_base::from_env"};
3634
if constexpr (requires { Scheduler(::beman::execution::get_scheduler(env)); }) {
37-
l.log("found scheduler");
3835
return Scheduler(::beman::execution::get_scheduler(env));
3936
} else {
40-
l.log("no scheduler");
4137
return Scheduler();
4238
}
4339
}
4440

45-
virtual std::coroutine_handle<> do_complete() = 0; // NOLINT(portability-template-virtual-member-function)
46-
virtual stop_token_type do_get_stop_token() = 0; // NOLINT(portability-template-virtual-member-function)
47-
virtual Environment& do_get_environment() = 0; // NOLINT(portability-template-virtual-member-function)
48-
virtual scheduler_type do_get_scheduler() = 0; // NOLINT(portability-template-virtual-member-function)
49-
virtual scheduler_type
50-
do_set_scheduler(scheduler_type other) = 0; // NOLINT(portability-template-virtual-member-function)
41+
// NOLINTBEGIN(portability-template-virtual-member-function)
42+
virtual auto do_complete() -> std::coroutine_handle<> = 0;
43+
virtual auto do_get_stop_token() -> stop_token_type = 0;
44+
virtual auto do_get_environment() -> Environment& = 0;
45+
virtual auto do_get_scheduler() -> scheduler_type = 0;
46+
virtual auto do_set_scheduler(scheduler_type other) -> scheduler_type = 0;
47+
// NOLINTEND(portability-template-virtual-member-function)
5148

5249
virtual ~state_base() = default;
5350
};

0 commit comments

Comments
 (0)