proxygen
TraceEventContext.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <cstdint>
13 #include <vector>
14 
15 namespace proxygen {
16 
17 struct TraceEventObserver;
18 class TraceEvent;
19 
21  public:
22  // Optional parent id for all sub trace events to add.
24 
26  std::vector<TraceEventObserver*> observers,
27  bool allTraceEventNeeded = false)
28  : parentID(pID)
29  , observers_(std::move(observers))
30  , allTraceEventNeeded_(allTraceEventNeeded) {}
31 
32  explicit TraceEventContext(uint32_t pID = 0,
33  TraceEventObserver* observer = nullptr,
34  bool allTraceEventNeeded = false)
35  : parentID(pID)
36  , allTraceEventNeeded_(allTraceEventNeeded) {
37  if (observer) {
38  observers_.push_back(observer);
39  }
40  }
41 
42  void traceEventAvailable(TraceEvent event);
43 
44  bool isAllTraceEventNeeded() const;
45 
46  private:
47  // Observer vector to observe all trace events about to occur
48  std::vector<TraceEventObserver*> observers_;
49 
50  // Whether the observers actually care about all trace events from this
51  // context or only necessary ones.
53 };
54 
55 }
TraceEventContext(uint32_t pID=0, TraceEventObserver *observer=nullptr, bool allTraceEventNeeded=false)
void traceEventAvailable(TraceEvent event)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
TraceEventContext(uint32_t pID, std::vector< TraceEventObserver * > observers, bool allTraceEventNeeded=false)
std::vector< TraceEventObserver * > observers_