diff options
author | eldritch horrors <pennae@lix.systems> | 2024-09-01 01:37:10 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-09-27 16:39:33 +0200 |
commit | cd1ceffb0ee9544bf14453f94da6b6f0d52f10cd (patch) | |
tree | eb055f15f9bf62ebb9fbb373056bd48703769203 /src/libstore/build/goal.cc | |
parent | 0478949c72310b9749d5b959adad8bdf5c2c0841 (diff) |
libstore: make waiting for a while a promise
this simplifies waitForInput quite a lot, and at the same time makes
polling less thundering-herd-y. it even fixes early polling wakeups!
Change-Id: I6dfa62ce91729b8880342117d71af5ae33366414
Diffstat (limited to 'src/libstore/build/goal.cc')
-rw-r--r-- | src/libstore/build/goal.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libstore/build/goal.cc b/src/libstore/build/goal.cc index 82861ad2b..649093dbd 100644 --- a/src/libstore/build/goal.cc +++ b/src/libstore/build/goal.cc @@ -1,4 +1,6 @@ #include "goal.hh" +#include "worker.hh" +#include <kj/time.h> namespace nix { @@ -15,4 +17,15 @@ void Goal::trace(std::string_view s) debug("%1%: %2%", name, s); } +kj::Promise<Result<Goal::WorkResult>> Goal::waitForAWhile() +try { + trace("wait for a while"); + /* If we are polling goals that are waiting for a lock, then wake + up after a few seconds at most. */ + co_await worker.aio.provider->getTimer().afterDelay(settings.pollInterval.get() * kj::SECONDS); + co_return ContinueImmediately{}; +} catch (...) { + co_return std::current_exception(); +} + } |