async: remove tag_invoke calls
P2300R9 removed usage of tag_invoke. stdexec still has it
but in order to be forward compliant with the C++26 standard
we should modernize the code and remove its usage. This also
has the benefit of simplifying most sender/receiver implementations.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ib0a1d0a82485c8d247a18daa020d0bba2249e95c
diff --git a/src/async/context.cpp b/src/async/context.cpp
index d4ec5e9..0b31391 100644
--- a/src/async/context.cpp
+++ b/src/async/context.cpp
@@ -34,8 +34,7 @@
// Called by the `caller` to indicate the Sender should be stopped.
virtual void stop() noexcept = 0;
- // Arm the completion event.
- void arm() noexcept;
+ void start() noexcept;
// Data to share with the worker.
event_t::time_resolution timeout{};
@@ -70,32 +69,25 @@
execution::set_value(std::move(this->receiver));
}
- friend void tag_invoke(execution::start_t,
- wait_process_operation& self) noexcept
- {
- self.arm();
- }
-
R receiver;
};
/* The sender for the wait/process event. */
struct wait_process_sender : public context_ref
{
- using is_sender = void;
+ using sender_concept = execution::sender_t;
explicit wait_process_sender(context& ctx) : context_ref(ctx) {}
- friend auto tag_invoke(execution::get_completion_signatures_t,
- const wait_process_sender&, auto)
+ template <typename Self, class... Env>
+ static constexpr auto get_completion_signatures(Self&&, Env&&...)
-> execution::completion_signatures<execution::set_value_t()>;
template <execution::receiver R>
- friend auto tag_invoke(execution::connect_t, wait_process_sender&& self,
- R r) -> wait_process_operation<R>
+ auto connect(R r) -> wait_process_operation<R>
{
// Create the completion for the wait.
- return {self.ctx, std::move(r)};
+ return {ctx, std::move(r)};
}
};
@@ -282,7 +274,7 @@
}
}
-void details::wait_process_completion::arm() noexcept
+void details::wait_process_completion::start() noexcept
{
// Call process. True indicates something was handled and we do not
// need to `wait`, because there might be yet another pending operation
diff --git a/src/async/fdio.cpp b/src/async/fdio.cpp
index 94c79d1..df54cf0 100644
--- a/src/async/fdio.cpp
+++ b/src/async/fdio.cpp
@@ -59,7 +59,7 @@
}
}
-void fdio_completion::arm() noexcept
+void fdio_completion::start() noexcept
{
// Set ourselves as the awaiting Receiver
std::unique_lock l{fdioInstance.lock};
diff --git a/src/async/match.cpp b/src/async/match.cpp
index bedce38..7d05ba6 100644
--- a/src/async/match.cpp
+++ b/src/async/match.cpp
@@ -42,7 +42,7 @@
}
}
-void match_ns::match_completion::arm() noexcept
+void match_ns::match_completion::start() noexcept
{
// Set ourselves as the awaiting Receiver and see if there is a message
// to immediately complete on.
diff --git a/src/async/mutex.cpp b/src/async/mutex.cpp
index 44694c6..19e5d3c 100644
--- a/src/async/mutex.cpp
+++ b/src/async/mutex.cpp
@@ -34,7 +34,7 @@
namespace mutex_ns
{
-void mutex_completion::arm() noexcept
+void mutex_completion::start() noexcept
{
std::unique_lock l{mutexInstance.lock};