async: timer: reduce co_await usage
Using the stdexec `transfer` method we can eliminate two co_awaits
and a task and instead return a sender that performs the `sleep_for`
operation.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I307fed9acd05d6ab93f59f3f3aa0056276cc0df0
diff --git a/include/sdbusplus/async/timer.hpp b/include/sdbusplus/async/timer.hpp
index 909fad3..02b135b 100644
--- a/include/sdbusplus/async/timer.hpp
+++ b/include/sdbusplus/async/timer.hpp
@@ -99,13 +99,12 @@
return {self.ctx, self.time, std::move(r)};
}
- static task<> sleep_for(context& ctx, event_t::time_resolution time)
+ static auto sleep_for(context& ctx, event_t::time_resolution time)
{
// Run the delay sender and then switch back to the worker thread.
// The delay completion happens from the sd-event handler, which is
// ran on the 'caller' thread.
- co_await sleep_sender(ctx, time);
- co_await execution::schedule(get_scheduler(ctx));
+ return execution::transfer(sleep_sender(ctx, time), get_scheduler(ctx));
}
private: