File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,21 +42,21 @@ mp::AnimatedSpinner::~AnimatedSpinner()
4242
4343void mp::AnimatedSpinner::start (const std::string& start_message)
4444{
45- if (!is_live)
46- {
47- current_message = start_message;
48- cout << start_message << std::flush;
49- return ;
50- }
51-
5245 std::unique_lock<decltype (mutex)> lock{mutex};
46+
5347 if (!running)
5448 {
5549 current_message = start_message;
5650 running = true ;
57- clear_line (cout);
58- cout << start_message << " " << std::flush;
59- t = std::thread (&AnimatedSpinner::draw, this );
51+
52+ if (is_live)
53+ {
54+ clear_line (cout);
55+ cout << start_message << " " << std::flush;
56+ t = std::thread (&AnimatedSpinner::draw, this );
57+ }
58+ else
59+ cout << start_message << std::flush;
6060 }
6161}
6262
@@ -68,19 +68,21 @@ void mp::AnimatedSpinner::start()
6868
6969void mp::AnimatedSpinner::stop ()
7070{
71- if (!is_live)
72- return ;
73-
7471 std::unique_lock<decltype (mutex)> lock{mutex};
7572 if (running)
7673 {
7774 running = false ;
78- cv.notify_one ();
79- lock.unlock ();
80- if (t.joinable ())
81- t.join ();
75+ if (is_live)
76+ {
77+ cv.notify_one ();
78+ lock.unlock ();
79+ if (t.joinable ())
80+ t.join ();
81+ }
8282 }
83- clear_line (cout);
83+
84+ if (is_live)
85+ clear_line (cout);
8486}
8587
8688void mp::AnimatedSpinner::print (std::ostream& stream, const std::string& message)
You can’t perform that action at this time.
0 commit comments