async: add sleep_for sender
Sometimes it is useful to do the equivalent of
`std::this_thread::sleep_for` in a co-routine context. Add a
sender-based implementation to async.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I9991eb40b7a1b12e61511f1200bc99fdcdbccf0a
diff --git a/src/async/context.cpp b/src/async/context.cpp
index 1dc9906..007a266 100644
--- a/src/async/context.cpp
+++ b/src/async/context.cpp
@@ -37,7 +37,7 @@
// Data to share with the worker.
context& ctx;
- std::chrono::microseconds timeout{};
+ event_t::time_resolution timeout{};
static task<> loop(context& ctx);
static void wait_once(context& ctx);
diff --git a/src/event.cpp b/src/event.cpp
index 295191d..badd43a 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -90,7 +90,7 @@
run_condition = add_condition(run_wakeup, this);
}
-void event::run_one(std::chrono::microseconds timeout)
+void event::run_one(time_resolution timeout)
{
auto l = obtain_lock<false>();
@@ -146,8 +146,7 @@
}
source event::add_oneshot_timer(sd_event_time_handler_t handler, void* data,
- std::chrono::microseconds time,
- std::chrono::microseconds accuracy)
+ time_resolution time, time_resolution accuracy)
{
auto l = obtain_lock();