12#include <shared_mutex>
50 virtual void set(_In_ T value)
88 lazy_progress(_In_
const std::chrono::nanoseconds& timeout = std::chrono::milliseconds(500)) :
112 virtual void set(_In_ T value)
114 if (value == m_start || value == m_end)
115 m_last = std::chrono::high_resolution_clock::now();
116 else if (value == m_value)
119 auto now = std::chrono::high_resolution_clock::now();
120 if (now - m_last < m_timeout)
135 std::chrono::nanoseconds m_timeout;
136 std::chrono::system_clock::time_point m_last;
137 T m_start, m_end, m_value;
156 m_deadline(std::chrono::high_resolution_clock::now() + timeout)
167 m_host->set_text(msg);
179 m_host->set_range(start, end);
187 virtual void set(_In_ T value)
210 (m_host && m_host->cancel()) ||
211 m_deadline < std::chrono::high_resolution_clock::now();
216 std::chrono::high_resolution_clock::time_point m_deadline;
266 m_global.start = start;
269 m_host->set_range(m_global.start, m_global.end);
280 m_section.start = start;
292 m_host->set_text(msg);
303 m_local.start = start;
312 virtual void set(_In_ T value)
315 T size = m_local.size();
318 m_host->set(((value - m_local.start) * m_section.size() / size) + m_section.start);
339 return m_host && m_host->cancel();
365 m_host_ref = this->
detach();
388 T m_start, m_end, m_value;
393 m_start(0), m_end(0),
404 std::shared_lock<std::shared_mutex> lk(m_host.m_mutex);
406 m_host.m_host->set_text(msg);
418 combined_start = m_host.m_start += start - m_start,
419 combined_end = m_host.m_end += end - m_end;
422 std::shared_lock<std::shared_mutex> lk(m_host.m_mutex);
424 m_host.m_host->set_range(combined_start, combined_end);
432 virtual void set(_In_ T value)
434 T combined_value = m_host.m_value += value - m_value;
436 std::shared_lock<std::shared_mutex> lk(m_host.m_mutex);
438 m_host.m_host->set(combined_value);
448 std::shared_lock<std::shared_mutex> lk(m_host.m_mutex);
450 m_host.m_host->show(
show);
458 std::shared_lock<std::shared_mutex> lk(m_host.m_mutex);
459 return m_host.m_host && m_host.m_host->cancel();
464 std::atomic<T> m_start, m_end, m_value;
465 std::vector<worker_progress> m_workers;
466 std::shared_mutex m_mutex;
477 m_start(0), m_end(0),
480 m_workers.reserve(num_workers);
481 for (
size_t i = 0; i < num_workers; ++i)
485 m_host->
set(m_value);
496 std::unique_lock<std::shared_mutex> lk(m_mutex);
500 m_host->
set(m_value);
511 std::unique_lock<std::shared_mutex> lk(m_mutex);
526 return m_workers[index];
Progress indicator for individual worker.
Definition progress.hpp:385
virtual void set(T value)
Set local current progress.
Definition progress.hpp:432
virtual bool cancel()
Query whether user requested abort.
Definition progress.hpp:456
virtual void show(bool show=true)
Show or hide progress.
Definition progress.hpp:446
virtual void set_range(T start, T end)
Set local extend of the progress indicator.
Definition progress.hpp:415
virtual void set_text(const char *msg)
Set progress indicator text.
Definition progress.hpp:402
Aggregated progress indicator.
Definition progress.hpp:379
progress< T > & operator[](size_t index)
Returns progress indicator for specific worker.
Definition progress.hpp:524
void attach(progress< T > *host)
Attach to a host progress indicator.
Definition progress.hpp:494
progress< T > * detach()
Detach host progress indicator.
Definition progress.hpp:509
aggregate_progress(size_t num_workers, progress< T > *host=nullptr)
Constructs a progress indicator.
Definition progress.hpp:475
Global progress indicator.
Definition progress.hpp:226
void set_section_range(T start, T end)
Set section extend of the progress indicator.
Definition progress.hpp:278
virtual void show(bool show=true)
Show or hide progress.
Definition progress.hpp:328
virtual bool cancel()
Query whether user requested abort.
Definition progress.hpp:337
virtual void set(T value)
Set local current progress.
Definition progress.hpp:312
virtual void set_text(const char *msg)
Set progress indicator text.
Definition progress.hpp:289
progress< T > * detach()
Detach host progress indicator.
Definition progress.hpp:251
void set_global_range(T start, T end)
Set global extend of the progress indicator.
Definition progress.hpp:264
global_progress(progress< T > *host=nullptr)
Constructs a progress indicator.
Definition progress.hpp:233
void attach(progress< T > *host)
Attach to a host progress indicator.
Definition progress.hpp:241
virtual void set_range(T start, T end)
Set local extend of the progress indicator.
Definition progress.hpp:301
Lazy progress indicator.
Definition progress.hpp:81
lazy_progress(const std::chrono::nanoseconds &timeout=std::chrono::milliseconds(500))
Constructs a lazy progress indicator.
Definition progress.hpp:88
virtual void set(T value)
Set current progress.
Definition progress.hpp:112
virtual void do_set()
Called when progress reporting is due. Should override this method to implement actual progress refre...
Definition progress.hpp:132
virtual void set_range(T start, T end)
Set progress range extent.
Definition progress.hpp:101
Progress indicator switcher.
Definition progress.hpp:354
Progress indicator base class.
Definition progress.hpp:22
virtual bool cancel()
Query whether user requested abort.
Definition progress.hpp:68
virtual void set_text(const char *msg)
Set progress indicator text.
Definition progress.hpp:29
virtual void show(bool show=true)
Show or hide progress.
Definition progress.hpp:60
virtual void set(T value)
Set current progress.
Definition progress.hpp:50
virtual void set_range(T start, T end)
Set progress range extent.
Definition progress.hpp:40
Timeout progress indicator.
Definition progress.hpp:147
virtual void set_range(T start, T end)
Set progress range extent.
Definition progress.hpp:176
virtual void set_text(const char *msg)
Set progress indicator text.
Definition progress.hpp:164
virtual void set(T value)
Set current progress.
Definition progress.hpp:187
virtual bool cancel()
Query whether user requested abort.
Definition progress.hpp:207
timeout_progress(const std::chrono::nanoseconds &timeout=std::chrono::seconds(60), progress< T > *host=nullptr)
Constructs a timeout progress indicator.
Definition progress.hpp:154
virtual void show(bool show=true)
Show or hide progress.
Definition progress.hpp:198
Numerical interval.
Definition interval.hpp:18