mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 00:06:16 +02:00
Logger, ProgressBar: add a way to pause/resume
Add new virtual methods pause and resume to the Logger class, and implement them in ProgressBar to allow to pause the bar refreshing.
This commit is contained in:
parent
4dcc0a1b76
commit
85df7e7ea2
2 changed files with 16 additions and 0 deletions
|
@ -72,6 +72,7 @@ private:
|
|||
uint64_t corruptedPaths = 0, untrustedPaths = 0;
|
||||
|
||||
bool active = true;
|
||||
bool paused = false;
|
||||
bool haveUpdate = true;
|
||||
};
|
||||
|
||||
|
@ -120,6 +121,17 @@ public:
|
|||
updateThread.join();
|
||||
}
|
||||
|
||||
void pause() override {
|
||||
state_.lock()->paused = true;
|
||||
writeToStderr("\r\e[K");
|
||||
}
|
||||
|
||||
void resume() override {
|
||||
state_.lock()->paused = false;
|
||||
writeToStderr("\r\e[K");
|
||||
updateCV.notify_one();
|
||||
}
|
||||
|
||||
bool isVerbose() override
|
||||
{
|
||||
return printBuildLogs;
|
||||
|
@ -338,6 +350,7 @@ public:
|
|||
{
|
||||
auto nextWakeup = std::chrono::milliseconds::max();
|
||||
|
||||
if (state.paused) return nextWakeup;
|
||||
state.haveUpdate = false;
|
||||
if (!state.active) return nextWakeup;
|
||||
|
||||
|
|
|
@ -72,6 +72,9 @@ public:
|
|||
|
||||
virtual void stop() { };
|
||||
|
||||
virtual void pause() { };
|
||||
virtual void resume() { };
|
||||
|
||||
// Whether the logger prints the whole build log
|
||||
virtual bool isVerbose() { return false; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue