File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -42,18 +42,18 @@ mp::AnimatedSpinner::~AnimatedSpinner()
4242
4343void mp::AnimatedSpinner::start (const std::string& start_message)
4444{
45+ if (!is_live)
46+ return ;
47+
4548 std::unique_lock<decltype (mutex)> lock{mutex};
4649 if (!running)
4750 {
4851 current_message = start_message;
4952 running = true ;
5053
51- if (is_live)
52- {
53- clear_line (cout);
54- cout << start_message << " " << std::flush;
55- t = std::thread (&AnimatedSpinner::draw, this );
56- }
54+ clear_line (cout);
55+ cout << start_message << " " << std::flush;
56+ t = std::thread (&AnimatedSpinner::draw, this );
5757 }
5858}
5959
@@ -65,6 +65,9 @@ void mp::AnimatedSpinner::start()
6565
6666void mp::AnimatedSpinner::stop ()
6767{
68+ if (!is_live)
69+ return ;
70+
6871 std::unique_lock<decltype (mutex)> lock{mutex};
6972 if (running)
7073 {
@@ -75,12 +78,15 @@ void mp::AnimatedSpinner::stop()
7578 t.join ();
7679 }
7780
78- if (is_live)
79- clear_line (cout);
81+
82+ clear_line (cout);
8083}
8184
8285void mp::AnimatedSpinner::print (std::ostream& stream, const std::string& message)
8386{
87+ if (!is_live)
88+ return ;
89+
8490 stop ();
8591
8692 stream << message;
You can’t perform that action at this time.
0 commit comments