xref: /aosp_15_r20/external/cronet/base/trace_event/trace_id_helper.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_TRACE_EVENT_TRACE_ID_HELPER_H_
6 #define BASE_TRACE_EVENT_TRACE_ID_HELPER_H_
7 
8 #include <cstdint>
9 
10 #include "base/base_export.h"
11 
12 namespace base {
13 namespace trace_event {
14 
15 // Returns an globally-unique id which can be used as a flow id or async event
16 // id. This is fast (powered by an memory-order-relaxed atomic int), so use this
17 // function instead of implementing your own counter and hashing it with a
18 // random value. However, consider using TRACE_ID_LOCAL(this) to avoid storing
19 // additional data if possible.
20 BASE_EXPORT uint64_t GetNextGlobalTraceId();
21 
22 }  // namespace trace_event
23 }  // namespace base
24 
25 #endif  // BASE_TRACE_EVENT_TRACE_ID_HELPER_H_
26