void EventRecorder::init()
{
+ std::lock_guard<std::mutex> lock{_mu};
+
_os << "{" << std::endl;
_os << " " << quote("traceEvents") << ": [\n";
}
-void EventRecorder::emit(const DurationEvent &evt) { _os << " " << object(evt) << ",\n"; }
-void EventRecorder::emit(const CounterEvent &evt) { _os << " " << object(evt) << ",\n"; }
+void EventRecorder::emit(const DurationEvent &evt)
+{
+ std::lock_guard<std::mutex> lock{_mu};
+
+ _os << " " << object(evt) << ",\n";
+}
+
+void EventRecorder::emit(const CounterEvent &evt)
+{
+ std::lock_guard<std::mutex> lock{_mu};
+
+ _os << " " << object(evt) << ",\n";
+}
void EventRecorder::fini()
{
+ std::lock_guard<std::mutex> lock{_mu};
+
_os << " { }\n";
_os << " ]\n";
_os << "}\n";