25#ifndef PXR_BASE_TRACE_EVENT_CONTAINER_H
26#define PXR_BASE_TRACE_EVENT_CONTAINER_H
30#include "pxr/base/trace/api.h"
31#include "pxr/base/trace/event.h"
37PXR_NAMESPACE_OPEN_SCOPE
55 static _Node* New(
size_t capacity);
59 static void DestroyList(_Node *head);
62 static void Join(_Node *lhs, _Node *rhs);
65 bool IsFull()
const {
return _end == _sentinel; }
68 const char *p =
reinterpret_cast<const char *
>(
this);
70 return reinterpret_cast<const TraceEvent *
>(p);
77 _Node *GetPrevNode() {
81 const _Node *GetPrevNode()
const {
85 _Node *GetNextNode() {
89 const _Node *GetNextNode()
const {
93 void ClaimEventEntry() {
125 using iterator_category = std::bidirectional_iterator_tag;
127 using difference_type = int64_t;
140 return !operator==(other);
144 return _event == other._event;
177 if (_event == _node->end() && _node->GetNextNode()) {
178 _node = _node->GetNextNode();
179 _event = _node->begin();
184 if (_event == _node->begin()) {
185 _node = _node->GetPrevNode();
186 _event = _node->end();
197 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
217 template <
class... Args>
220 new (_nextEvent++)
TraceEvent(std::forward<Args>(args)...);
221 _back->ClaimEventEntry();
222 if (_back->IsFull()) {
228 const_iterator begin()
const {
229 return const_iterator(_front, _front ? _front->begin() :
nullptr);
232 const_iterator end()
const {
233 return const_iterator(_back, _back ? _back->end() :
nullptr);
236 const_reverse_iterator rbegin()
const {
237 return const_reverse_iterator(end());
240 const_reverse_iterator rend()
const {
241 return const_reverse_iterator(begin());
244 bool empty()
const {
return begin() == end(); }
253 TRACE_API
void Allocate();
259 size_t _blockSizeBytes;
262PXR_NAMESPACE_CLOSE_SCOPE
Bidirectional iterator of TraceEvents.
Holds TraceEvent instances.
TraceEventContainer(TraceEventContainer &&)
Move Constructor.
TraceEventContainer & operator=(TraceEventContainer &&)
Move Assignment.
TraceEventContainer()
Constructor.
TRACE_API void Append(TraceEventContainer &&other)
Append the events in other to the end of this container.
This represents an event recorded by a TraceCollector.