24 std::optional<uint64_t> total,
26 : m_details(details), m_completed(0),
27 m_total(
Progress::kNonDeterministicTotal),
28 m_progress_data{title, ++g_id,
36 std::lock_guard<std::mutex> guard(
m_mutex);
47 std::lock_guard<std::mutex> guard(
m_mutex);
57 std::optional<std::string> updated_detail) {
59 std::lock_guard<std::mutex> guard(
m_mutex);
61 m_details = std::move(updated_detail.value());
84 : m_entries(), m_alarm(std::chrono::milliseconds(100)) {}
101 assert(
InstanceImpl() &&
"ProgressManager must be initialized");
106 static std::optional<ProgressManager> g_progress_manager;
107 return g_progress_manager;
113 llvm::StringRef key = progress_data.
title;
114 bool new_entry = !
m_entries.contains(key);
121 entry.
data = progress_data;
142 llvm::StringRef key = progress_data.
title;
156 std::string key_str = std::string(key);
169 const uint64_t completed =
static constexpr Handle INVALID_HANDLE
bool Cancel(Handle handle)
Cancel the alarm for the given Handle.
Handle Create(Callback callback)
Create an alarm for the given callback.
A class to manage flag bits.
static void ReportProgress(uint64_t progress_id, std::string title, std::string details, uint64_t completed, uint64_t total, std::optional< lldb::user_id_t > debugger_id, uint32_t progress_category_bit=lldb::eBroadcastBitProgress)
Report progress events.
A class used to group progress reports by category.
void Decrement(const Progress::ProgressData &)
static void ReportProgress(const Progress::ProgressData &progress_data, EventType type)
Alarm m_alarm
Alarm instance to coalesce progress events.
static ProgressManager & Instance()
void Expire(llvm::StringRef key)
Helper function for reporting progress when the alarm in the corresponding entry in the map expires.
static std::optional< ProgressManager > & InstanceImpl()
llvm::StringMap< Entry > m_entries
Map used for bookkeeping.
void Increment(const Progress::ProgressData &)
Control the refcount of the progress report category as needed.
std::mutex m_entries_mutex
Mutex to provide the map.
A Progress indicator helper class.
bool m_complete
Set to true when progress has been reported where m_completed == m_total to ensure that we don't send...
void Increment(uint64_t amount=1, std::optional< std::string > updated_detail={})
Increment the progress and send a notification to the installed callback.
uint64_t m_completed
How much work ([0...m_total]) that has been completed.
static std::atomic< uint64_t > g_id
std::string m_details
More specific information about the current file being displayed in the report.
static constexpr uint64_t kNonDeterministicTotal
Used to indicate a non-deterministic progress report.
uint64_t m_total
Total amount of work, use a std::nullopt in the constructor for non deterministic progress.
~Progress()
Destroy the progress object.
ProgressData m_progress_data
Data needed by the debugger to broadcast a progress event.
Progress(std::string title, std::string details={}, std::optional< uint64_t > total=std::nullopt, lldb_private::Debugger *debugger=nullptr)
Construct a progress object that will report information.
A class that represents a running process on the host machine.
@ eBroadcastBitProgressCategory
Entry used for bookkeeping.
Progress::ProgressData data
Data used to emit progress events.
Alarm::Handle handle
Alarm handle used when the refcount reaches zero.
uint64_t refcount
Reference count used for overlapping events.
Data belonging to this Progress event that is used for bookkeeping by ProgressManager.
std::optional< lldb::user_id_t > debugger_id
The optional debugger ID to report progress to.
std::string title
The title of the progress activity, also used as a category.
uint64_t progress_id
A unique integer identifier for progress reporting.
lldb::user_id_t GetID() const
Get accessor for the user ID.