aboutsummaryrefslogtreecommitdiff
path: root/src/libmain
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmain')
-rw-r--r--src/libmain/progress-bar.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc
index 5c648ccf7..1a68daca2 100644
--- a/src/libmain/progress-bar.cc
+++ b/src/libmain/progress-bar.cc
@@ -12,6 +12,8 @@
namespace nix {
+using namespace std::literals::chrono_literals;
+
static std::string_view getS(const std::vector<Logger::Field> & fields, size_t n)
{
assert(n < fields.size());
@@ -33,6 +35,9 @@ static std::string_view storePathToName(std::string_view path)
return i == std::string::npos ? base.substr(0, 0) : base.substr(i + 1);
}
+// 100 years ought to be enough for anyone (yet sufficiently smaller than max() to not cause signed integer overflow).
+constexpr const auto A_LONG_TIME = std::chrono::duration_cast<std::chrono::milliseconds>(100 * 365 * 86400s);
+
class ProgressBar : public Logger
{
private:
@@ -93,7 +98,7 @@ public:
state_.lock()->active = isTTY;
updateThread = std::thread([&]() {
auto state(state_.lock());
- auto nextWakeup = std::chrono::milliseconds::max();
+ auto nextWakeup = A_LONG_TIME;
while (state->active) {
if (!state->haveUpdate)
state.wait_for(updateCV, nextWakeup);
@@ -350,7 +355,7 @@ public:
std::chrono::milliseconds draw(State & state)
{
- auto nextWakeup = std::chrono::milliseconds::max();
+ auto nextWakeup = A_LONG_TIME;
state.haveUpdate = false;
if (state.paused || !state.active) return nextWakeup;