libstore: turn waitForInput into a promise
Change-Id: I8355d8d3f6c43a812990c1912b048e5735b07f7b
This commit is contained in:
parent
8e05cc1e6c
commit
d31310bf59
|
@ -328,7 +328,7 @@ std::vector<GoalPtr> Worker::run(std::function<Targets (GoalFactory &)> req)
|
||||||
|
|
||||||
/* Wait for input. */
|
/* Wait for input. */
|
||||||
if (!children.isEmpty())
|
if (!children.isEmpty())
|
||||||
waitForInput();
|
waitForInput().wait(aio.waitScope).value();
|
||||||
else {
|
else {
|
||||||
assert(!awake.empty());
|
assert(!awake.empty());
|
||||||
}
|
}
|
||||||
|
@ -351,8 +351,8 @@ std::vector<GoalPtr> Worker::run(std::function<Targets (GoalFactory &)> req)
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::waitForInput()
|
kj::Promise<Result<void>> Worker::waitForInput()
|
||||||
{
|
try {
|
||||||
printMsg(lvlVomit, "waiting for children");
|
printMsg(lvlVomit, "waiting for children");
|
||||||
|
|
||||||
auto waitFor = [&]{
|
auto waitFor = [&]{
|
||||||
|
@ -366,7 +366,10 @@ void Worker::waitForInput()
|
||||||
waitFor = waitFor.exclusiveJoin(aio.provider->getTimer().afterDelay(10 * kj::SECONDS));
|
waitFor = waitFor.exclusiveJoin(aio.provider->getTimer().afterDelay(10 * kj::SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
waitFor.wait(aio.waitScope);
|
co_await waitFor;
|
||||||
|
co_return result::success();
|
||||||
|
} catch (...) {
|
||||||
|
co_return result::failure(std::current_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* Wait for input to become available.
|
* Wait for input to become available.
|
||||||
*/
|
*/
|
||||||
void waitForInput();
|
kj::Promise<Result<void>> waitForInput();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a dead goal.
|
* Remove a dead goal.
|
||||||
|
|
Loading…
Reference in a new issue