diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-11-30 09:55:05 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-11-30 09:55:05 +0000 |
| commit | 61b3dfd1844799d29ac1f090a1e674d5a3439dc7 (patch) | |
| tree | 7c92b223eb428fc531a3fe071156fc262563ea93 /src/shell_manager.cc | |
| parent | 540e504e68417d68cdd522c5d5924b61e612888f (diff) | |
Use a Timer for Shell waiting notification
Without a timer we were relying on other event sources to wake us
up to display the information, which was usually a NormalIdle or
a filesystem check timer.
Diffstat (limited to 'src/shell_manager.cc')
| -rw-r--r-- | src/shell_manager.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 1ee1c280..698c7fc7 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -191,7 +191,14 @@ std::pair<String, int> ShellManager::eval( using namespace std::chrono; static constexpr seconds wait_timeout{1}; - auto next_wait_notification = duration_cast<milliseconds>(wait_timeout); + Timer wait_timer{wait_time + wait_timeout, [&](Timer& timer) + { + auto wait_duration = Clock::now() - wait_time; + context.print_status({ format("waiting for shell command to finish ({}s)", + duration_cast<seconds>(wait_duration).count()), + get_face("Information") }, true); + timer.set_next_date(Clock::now() + wait_timeout); + }, EventMode::Urgent}; while (not terminated or ((flags & Flags::WaitForStdout) and @@ -200,15 +207,6 @@ std::pair<String, int> ShellManager::eval( EventManager::instance().handle_next_events(EventMode::Urgent, &orig_mask); if (not terminated) terminated = waitpid(pid, &status, WNOHANG); - - auto wait_duration = Clock::now() - wait_time; - if (wait_duration > next_wait_notification) - { - next_wait_notification = duration_cast<milliseconds>(wait_duration + wait_timeout); - context.print_status({ format("waiting for shell command to finish ({}s)", - duration_cast<seconds>(wait_duration).count()), - get_face("Information") }, true); - } } if (not stderr_contents.empty()) |
