aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/goal.cc
blob: 649093dbd6af1e40341dd07dffc40147b6807633 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "goal.hh"
#include "worker.hh"
#include <kj/time.h>

namespace nix {


bool CompareGoalPtrs::operator() (const GoalPtr & a, const GoalPtr & b) const {
    std::string s1 = a->key();
    std::string s2 = b->key();
    return s1 < s2;
}


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();
}

}