9
9
#ifndef LLDB_CORE_PROGRESS_H
10
10
#define LLDB_CORE_PROGRESS_H
11
11
12
- #include " lldb/Host/Alarm.h"
13
12
#include " lldb/Utility/Timeout.h"
14
13
#include " lldb/lldb-forward.h"
15
14
#include " lldb/lldb-types.h"
18
17
#include < cstdint>
19
18
#include < mutex>
20
19
#include < optional>
20
+ #include < string>
21
21
22
22
namespace lldb_private {
23
23
@@ -115,21 +115,6 @@ class Progress {
115
115
// / Used to indicate a non-deterministic progress report
116
116
static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
117
117
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
-
133
118
private:
134
119
void ReportProgress ();
135
120
static std::atomic<uint64_t > g_id;
@@ -141,8 +126,18 @@ class Progress {
141
126
// Minimum amount of time between two progress reports.
142
127
const Timeout<std::nano> m_minimum_report_time;
143
128
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;
146
141
147
142
// / How much work ([0...m_total]) that has been completed.
148
143
std::atomic<uint64_t > m_completed = 0 ;
@@ -161,60 +156,6 @@ class Progress {
161
156
std::optional<uint64_t > m_prev_completed;
162
157
};
163
158
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
-
218
159
} // namespace lldb_private
219
160
220
161
#endif // LLDB_CORE_PROGRESS_H
0 commit comments