// Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #pragma once #include #include #include #include #include namespace anki { /// @addtogroup core /// @{ /// A system that sits on top of the tracer and processes the counters and events. class CoreTracer { public: CoreTracer(); ~CoreTracer(); /// @param directory The directory to store the trace and counters. ANKI_USE_RESULT Error init(GenericMemoryPoolAllocator alloc, CString directory); /// It will flush everything. void flushFrame(U64 frame); private: class ThreadWorkItem; class PerFrameCounters; GenericMemoryPoolAllocator m_alloc; Thread m_thread; ConditionVariable m_cvar; Mutex m_mtx; DynamicArray m_counterNames; IntrusiveList m_frameCounters; IntrusiveList m_workItems; ///< Items for the thread to process. File m_traceJsonFile; File m_countersCsvFile; Bool m_quit = false; Error threadWorker(); Error writeEvents(ThreadWorkItem& item); void gatherCounters(ThreadWorkItem& item); Error writeCountersForReal(); }; /// @} } // end namespace anki