From bf3a23b8d22aba3f50e0e9e2bfe64666ba41c514 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 19 Apr 2019 19:07:12 -0700 Subject: [PATCH] construct/console: Eliminate extra sleep() after output done. --- construct/console.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/construct/console.cc b/construct/console.cc index ceea9cef6..3a6ca985d 100644 --- a/construct/console.cc +++ b/construct/console.cc @@ -302,7 +302,7 @@ construct::console::handle_line_bymodule() // configured number of milliseconds. If these settings are too // aggressive then the output heading to stdout won't appear in // the terminal after the buffers are filled. - for(size_t off(0); off < str.size(); off += size_t(ratelimit_bytes)) + size_t off(0); if(off < str.size()) do { const string_view substr { @@ -310,8 +310,13 @@ construct::console::handle_line_bymodule() }; std::cout << substr << std::flush; + off += size_t(ratelimit_bytes); + if(off >= str.size()) + break; + ctx::sleep(milliseconds(ratelimit_sleep)); } + while(1); if(!endswith(str, '\n')) std::cout << std::endl;