aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/progress-bar.cc
diff options
context:
space:
mode:
authorAlexander Bantyev <balsoft@balsoft.ru>2023-03-09 18:11:01 +0400
committerAlexander Bantyev <balsoft@balsoft.ru>2023-03-22 09:45:08 +0400
commit85df7e7ea24b9f7badbcec06a54e144a0cf1baf5 (patch)
tree0b89e66f84cae891aa047cdb8c4db40a13fd5b65 /src/libmain/progress-bar.cc
parent4dcc0a1b766be6242ad5b478b88fd59d5081446f (diff)
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.
Diffstat (limited to 'src/libmain/progress-bar.cc')
-rw-r--r--src/libmain/progress-bar.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc
index 024259584..882deb169 100644
--- a/src/libmain/progress-bar.cc
+++ b/src/libmain/progress-bar.cc
@@ -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;