forked from firka/flutter
Wrap the global timeline event handler callback in a std::atomic (flutter/engine#32073)
This commit is contained in:
@@ -19,7 +19,7 @@ namespace tracing {
|
||||
|
||||
namespace {
|
||||
AsciiTrie gAllowlist;
|
||||
TimelineEventHandler gTimelineEventHandler;
|
||||
std::atomic<TimelineEventHandler> gTimelineEventHandler;
|
||||
|
||||
inline void FlutterTimelineEvent(const char* label,
|
||||
int64_t timestamp0,
|
||||
@@ -28,9 +28,11 @@ inline void FlutterTimelineEvent(const char* label,
|
||||
intptr_t argument_count,
|
||||
const char** argument_names,
|
||||
const char** argument_values) {
|
||||
if (gTimelineEventHandler && gAllowlist.Query(label)) {
|
||||
gTimelineEventHandler(label, timestamp0, timestamp1_or_async_id, type,
|
||||
argument_count, argument_names, argument_values);
|
||||
TimelineEventHandler handler =
|
||||
gTimelineEventHandler.load(std::memory_order_relaxed);
|
||||
if (handler && gAllowlist.Query(label)) {
|
||||
handler(label, timestamp0, timestamp1_or_async_id, type, argument_count,
|
||||
argument_names, argument_values);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -147,13 +147,13 @@ using TraceIDArg = int64_t;
|
||||
|
||||
void TraceSetAllowlist(const std::vector<std::string>& allowlist);
|
||||
|
||||
using TimelineEventHandler = std::function<void(const char*,
|
||||
int64_t,
|
||||
int64_t,
|
||||
Dart_Timeline_Event_Type,
|
||||
intptr_t,
|
||||
const char**,
|
||||
const char**)>;
|
||||
typedef void (*TimelineEventHandler)(const char*,
|
||||
int64_t,
|
||||
int64_t,
|
||||
Dart_Timeline_Event_Type,
|
||||
intptr_t,
|
||||
const char**,
|
||||
const char**);
|
||||
|
||||
void TraceSetTimelineEventHandler(TimelineEventHandler handler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user