99#ifndef LLDB_CORE_PROGRESS_H
1010#define LLDB_CORE_PROGRESS_H
1111
12- #include " lldb/Host/Alarm.h"
1312#include " lldb/Utility/Timeout.h"
1413#include " lldb/lldb-forward.h"
1514#include " lldb/lldb-types.h"
1817#include < cstdint>
1918#include < mutex>
2019#include < optional>
20+ #include < string>
2121
2222namespace lldb_private {
2323
@@ -115,21 +115,6 @@ class Progress {
115115 // / Used to indicate a non-deterministic progress report
116116 static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
117117
118- // / Data belonging to this Progress event that is used for bookkeeping by
119- // / ProgressManager.
120- struct ProgressData {
121- // / The title of the progress activity, also used as a category.
122- std::string title;
123- // / A unique integer identifier for progress reporting.
124- uint64_t progress_id;
125- // / The optional debugger ID to report progress to. If this has no value
126- // / then all debuggers will receive this event.
127- std::optional<lldb::user_id_t > debugger_id;
128-
129- // / The origin of the progress event, wheter it is internal or external.
130- Origin origin;
131- };
132-
133118private:
134119 void ReportProgress ();
135120 static std::atomic<uint64_t > g_id;
@@ -141,8 +126,18 @@ class Progress {
141126 // Minimum amount of time between two progress reports.
142127 const Timeout<std::nano> m_minimum_report_time;
143128
144- // / Data needed by the debugger to broadcast a progress event.
145- const ProgressData m_progress_data;
129+ // / The title of the progress activity, also used as a category.
130+ const std::string m_title;
131+
132+ // / A unique integer identifier for progress reporting.
133+ const uint64_t m_progress_id;
134+
135+ // / The optional debugger ID to report progress to. If this has no value
136+ // / then all debuggers will receive this event.
137+ const std::optional<lldb::user_id_t > m_debugger_id;
138+
139+ // / The origin of the progress event, whether it is internal or external.
140+ const Origin m_origin;
146141
147142 // / How much work ([0...m_total]) that has been completed.
148143 std::atomic<uint64_t > m_completed = 0 ;
@@ -161,60 +156,6 @@ class Progress {
161156 std::optional<uint64_t > m_prev_completed;
162157};
163158
164- // / A class used to group progress reports by category. This is done by using a
165- // / map that maintains a refcount of each category of progress reports that have
166- // / come in. Keeping track of progress reports this way will be done if a
167- // / debugger is listening to the eBroadcastBitProgressByCategory broadcast bit.
168- class ProgressManager {
169- public:
170- ProgressManager ();
171- ~ProgressManager ();
172-
173- // / Control the refcount of the progress report category as needed.
174- void Increment (const Progress::ProgressData &);
175- void Decrement (const Progress::ProgressData &);
176-
177- static void Initialize ();
178- static void Terminate ();
179- static bool Enabled ();
180- static ProgressManager &Instance ();
181-
182- protected:
183- enum class EventType {
184- Begin,
185- End,
186- };
187- static void ReportProgress (const Progress::ProgressData &progress_data,
188- EventType type);
189-
190- static std::optional<ProgressManager> &InstanceImpl ();
191-
192- // / Helper function for reporting progress when the alarm in the corresponding
193- // / entry in the map expires.
194- void Expire (llvm::StringRef key);
195-
196- // / Entry used for bookkeeping.
197- struct Entry {
198- // / Reference count used for overlapping events.
199- uint64_t refcount = 0 ;
200-
201- // / Data used to emit progress events.
202- Progress::ProgressData data;
203-
204- // / Alarm handle used when the refcount reaches zero.
205- Alarm::Handle handle = Alarm::INVALID_HANDLE;
206- };
207-
208- // / Map used for bookkeeping.
209- llvm::StringMap<Entry> m_entries;
210-
211- // / Mutex to provide the map.
212- std::mutex m_entries_mutex;
213-
214- // / Alarm instance to coalesce progress events.
215- Alarm m_alarm;
216- };
217-
218159} // namespace lldb_private
219160
220161#endif // LLDB_CORE_PROGRESS_H
0 commit comments