File size: 1,401 Bytes
eef2bb1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #ifndef __TRACY__THREADCOMPRESS_HPP__
#define __TRACY__THREADCOMPRESS_HPP__
#include <assert.h>
#include <stdint.h>
#include "../public/common/TracyForceInline.hpp"
#include "tracy_robin_hood.h"
#include "TracyVector.hpp"
namespace tracy
{
class FileRead;
class FileWrite;
class ThreadCompress
{
public:
ThreadCompress();
void InitZero();
void Load( FileRead& f );
void Save( FileWrite& f ) const;
tracy_force_inline uint16_t CompressThread( uint64_t thread )
{
if( m_threadLast.first == thread ) return m_threadLast.second;
return CompressThreadReal( thread );
}
tracy_force_inline uint64_t DecompressThread( uint16_t thread ) const
{
assert( thread < m_threadExpand.size() );
return m_threadExpand[thread];
}
tracy_force_inline uint16_t DecompressMustRaw( uint64_t thread ) const
{
auto it = m_threadMap.find( thread );
assert( it != m_threadMap.end() );
return it->second;
}
tracy_force_inline bool Exists( uint64_t thread ) const
{
return m_threadMap.find( thread ) != m_threadMap.end();
}
private:
uint16_t CompressThreadReal( uint64_t thread );
uint16_t CompressThreadNew( uint64_t thread );
unordered_flat_map<uint64_t, uint16_t> m_threadMap;
Vector<uint64_t> m_threadExpand;
std::pair<uint64_t, uint16_t> m_threadLast;
};
}
#endif
|