Definition at line 138 of file utilities.cpp.
◆ ProgressImpl()
cif::ProgressImpl::ProgressImpl |
( |
int64_t |
inMax, |
|
|
const std::string & |
inAction |
|
) |
| |
|
inline |
◆ PrintDone()
void cif::ProgressImpl::PrintDone |
( |
| ) |
|
Definition at line 328 of file utilities.cpp.
330 std::chrono::duration<double> elapsed = std::chrono::system_clock::now() -
mStart;
332 std::ostringstream msgstr;
333 msgstr <<
mAction <<
" done in " << elapsed <<
" seconds";
334 auto msg = msgstr.str();
338 if (msg.length() < width)
339 msg += std::string(width - msg.length(),
' ');
341 std::cout <<
'\r' << msg << std::endl;
uint32_t get_terminal_width()
std::chrono::time_point< std::chrono::system_clock > mStart
◆ PrintProgress()
void cif::ProgressImpl::PrintProgress |
( |
| ) |
|
Definition at line 206 of file utilities.cpp.
220 const char *kBlocks[] = {
235 msg.reserve(width + 1);
239 if (msg.length() < 20)
240 msg.append(20 - msg.length(),
' ');
243 msg =
mMessage.substr(0, 17) +
"...";
248 float progress =
static_cast<float>(consumed) /
mMax;
249 int pi =
static_cast<int>(std::ceil(progress * 33 * 8));
255 for (
int i = 0;
i < 33; ++
i)
268 const char kSpinner[] = {
' ',
'.',
'o',
'O',
'0',
'O',
'o',
'.'};
269 const size_t kSpinnerCount =
sizeof(kSpinner);
288 std::cout <<
'\r' << msg;
uint32_t get_terminal_width()
std::atomic< int64_t > mConsumed
◆ Run()
void cif::ProgressImpl::Run |
( |
| ) |
|
Definition at line 172 of file utilities.cpp.
176 bool printedAny =
false;
182 std::this_thread::sleep_for(2s);
184 std::unique_lock lock(
mMutex);
189 auto elapsed = std::chrono::system_clock::now() -
mStart;
191 if (elapsed < std::chrono::seconds(5))
std::atomic< int64_t > mConsumed
std::chrono::time_point< std::chrono::system_clock > mStart
◆ Stop()
void cif::ProgressImpl::Stop |
( |
| ) |
|
|
inline |
◆ mAction
std::string cif::ProgressImpl::mAction |
◆ mConsumed
std::atomic<int64_t> cif::ProgressImpl::mConsumed |
◆ mLastConsumed
int64_t cif::ProgressImpl::mLastConsumed = 0 |
◆ mMax
int64_t cif::ProgressImpl::mMax |
◆ mMessage
std::string cif::ProgressImpl::mMessage |
◆ mMutex
◆ mSpinnerIndex
int cif::ProgressImpl::mSpinnerIndex = 0 |
◆ mStart
std::chrono::time_point<std::chrono::system_clock> cif::ProgressImpl::mStart = std::chrono::system_clock::now() |
◆ mStop
bool cif::ProgressImpl::mStop = false |
◆ mThread
std::thread cif::ProgressImpl::mThread |
The documentation for this struct was generated from the following file: