This method is performance critical and should be kept fast. It is called when tracing starts/stops. The mutex is held, so no threads can be registered/unregistered. This prevents calling ThreadLocalRecorder::Clear from two different threads.
| 203 | // registered/unregistered. This prevents calling ThreadLocalRecorder::Clear |
| 204 | // from two different threads. |
| 205 | TraceMeRecorder::Events TraceMeRecorder::Clear() { |
| 206 | TraceMeRecorder::Events result; |
| 207 | std::swap(orphaned_events_, result); |
| 208 | for (const auto& entry : threads_) { |
| 209 | auto* recorder = entry.second; |
| 210 | result.push_back(recorder->Clear()); |
| 211 | } |
| 212 | return result; |
| 213 | } |
| 214 | |
| 215 | bool TraceMeRecorder::StartRecording(int level) { |
| 216 | level = std::max(0, level); |