mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Queue must be always able to alloc.
This commit is contained in:
parent
a03734afa6
commit
89928fde7b
18
TracyLua.hpp
18
TracyLua.hpp
@ -183,7 +183,7 @@ static tracy_force_inline void SendLuaCallstack( lua_State* L, uint32_t depth )
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::CallstackAlloc );
|
||||
MemWrite( &item->callstackAlloc.ptr, (uint64_t)ptr );
|
||||
MemWrite( &item->callstackAlloc.nativePtr, (uint64_t)Callstack( depth ) );
|
||||
@ -231,7 +231,7 @@ static inline int LuaZoneBeginS( lua_State* L )
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) );
|
||||
@ -298,7 +298,7 @@ static inline int LuaZoneBeginNS( lua_State* L )
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) );
|
||||
@ -365,7 +365,7 @@ static inline int LuaZoneBegin( lua_State* L )
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLoc );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) );
|
||||
@ -428,7 +428,7 @@ static inline int LuaZoneBeginN( lua_State* L )
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLoc );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) );
|
||||
@ -461,7 +461,7 @@ static inline int LuaZoneEnd( lua_State* L )
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneEnd );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
MemWrite( &item->zoneEnd.time, Profiler::GetTime( item->zoneEnd.cpu ) );
|
||||
@ -496,7 +496,7 @@ static inline int LuaZoneText( lua_State* L )
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneText );
|
||||
MemWrite( &item->zoneText.thread, thread );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
@ -525,7 +525,7 @@ static inline int LuaZoneName( lua_State* L )
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneName );
|
||||
MemWrite( &item->zoneText.thread, thread );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
@ -549,7 +549,7 @@ static inline int LuaMessage( lua_State* L )
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::Message );
|
||||
MemWrite( &item->message.time, Profiler::GetTime() );
|
||||
MemWrite( &item->message.thread, thread );
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuNewContext );
|
||||
MemWrite( &item->gpuNewContext.cpuTime, tcpu );
|
||||
MemWrite( &item->gpuNewContext.gpuTime, tgpu );
|
||||
@ -148,7 +148,7 @@ public:
|
||||
uint64_t time;
|
||||
glGetQueryObjectui64v( m_query[m_tail], GL_QUERY_RESULT, &time );
|
||||
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuTime );
|
||||
MemWrite( &item->gpuTime.gpuTime, (int64_t)time );
|
||||
MemWrite( &item->gpuTime.queryId, (uint16_t)m_tail );
|
||||
@ -202,7 +202,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuZoneBegin );
|
||||
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
|
||||
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
|
||||
@ -227,7 +227,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuZoneBeginCallstack );
|
||||
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
|
||||
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
|
||||
@ -250,7 +250,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuZoneEnd );
|
||||
MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() );
|
||||
MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) );
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuNewContext );
|
||||
MemWrite( &item->gpuNewContext.cpuTime, tcpu );
|
||||
MemWrite( &item->gpuNewContext.gpuTime, tgpu );
|
||||
@ -162,7 +162,7 @@ public:
|
||||
|
||||
for( unsigned int idx=0; idx<cnt; idx++ )
|
||||
{
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuTime );
|
||||
MemWrite( &item->gpuTime.gpuTime, m_res[idx] );
|
||||
MemWrite( &item->gpuTime.queryId, uint16_t( m_tail + idx ) );
|
||||
@ -222,7 +222,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuZoneBegin );
|
||||
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
|
||||
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
|
||||
@ -250,7 +250,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuZoneBeginCallstack );
|
||||
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
|
||||
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
|
||||
@ -273,7 +273,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::GpuZoneEnd );
|
||||
MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() );
|
||||
MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) );
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockAnnounce );
|
||||
MemWrite( &item->lockAnnounce.id, m_id );
|
||||
MemWrite( &item->lockAnnounce.time, Profiler::GetTime() );
|
||||
@ -49,7 +49,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockTerminate );
|
||||
MemWrite( &item->lockTerminate.id, m_id );
|
||||
MemWrite( &item->lockTerminate.time, Profiler::GetTime() );
|
||||
@ -85,7 +85,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockWait );
|
||||
MemWrite( &item->lockWait.id, m_id );
|
||||
MemWrite( &item->lockWait.thread, thread );
|
||||
@ -100,7 +100,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockObtain );
|
||||
MemWrite( &item->lockObtain.id, m_id );
|
||||
MemWrite( &item->lockObtain.thread, thread );
|
||||
@ -127,7 +127,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockRelease );
|
||||
MemWrite( &item->lockRelease.id, m_id );
|
||||
MemWrite( &item->lockRelease.thread, thread );
|
||||
@ -160,7 +160,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockObtain );
|
||||
MemWrite( &item->lockObtain.id, m_id );
|
||||
MemWrite( &item->lockObtain.thread, thread );
|
||||
@ -188,7 +188,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockMark );
|
||||
MemWrite( &item->lockMark.id, m_id );
|
||||
MemWrite( &item->lockMark.thread, thread );
|
||||
@ -223,7 +223,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockAnnounce );
|
||||
MemWrite( &item->lockAnnounce.id, m_id );
|
||||
MemWrite( &item->lockAnnounce.time, Profiler::GetTime() );
|
||||
@ -245,7 +245,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockTerminate );
|
||||
MemWrite( &item->lockTerminate.id, m_id );
|
||||
MemWrite( &item->lockTerminate.time, Profiler::GetTime() );
|
||||
@ -281,7 +281,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockWait );
|
||||
MemWrite( &item->lockWait.id, m_id );
|
||||
MemWrite( &item->lockWait.thread, thread );
|
||||
@ -296,7 +296,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockObtain );
|
||||
MemWrite( &item->lockObtain.id, m_id );
|
||||
MemWrite( &item->lockObtain.thread, thread );
|
||||
@ -323,7 +323,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockRelease );
|
||||
MemWrite( &item->lockRelease.id, m_id );
|
||||
MemWrite( &item->lockRelease.thread, thread );
|
||||
@ -356,7 +356,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockObtain );
|
||||
MemWrite( &item->lockObtain.id, m_id );
|
||||
MemWrite( &item->lockObtain.thread, thread );
|
||||
@ -390,7 +390,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockSharedWait );
|
||||
MemWrite( &item->lockWait.id, m_id );
|
||||
MemWrite( &item->lockWait.thread, thread );
|
||||
@ -405,7 +405,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockSharedObtain );
|
||||
MemWrite( &item->lockObtain.id, m_id );
|
||||
MemWrite( &item->lockObtain.thread, thread );
|
||||
@ -432,7 +432,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockSharedRelease );
|
||||
MemWrite( &item->lockRelease.id, m_id );
|
||||
MemWrite( &item->lockRelease.thread, thread );
|
||||
@ -465,7 +465,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockSharedObtain );
|
||||
MemWrite( &item->lockObtain.id, m_id );
|
||||
MemWrite( &item->lockObtain.thread, thread );
|
||||
@ -493,7 +493,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::LockMark );
|
||||
MemWrite( &item->lockMark.id, m_id );
|
||||
MemWrite( &item->lockMark.thread, thread );
|
||||
|
@ -628,7 +628,7 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::CrashReport );
|
||||
item->crashReport.time = Profiler::GetTime();
|
||||
item->crashReport.thread = thread;
|
||||
@ -670,7 +670,7 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::Crash );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
@ -866,7 +866,7 @@ static void CrashHandler( int signal, siginfo_t* info, void* /*ucontext*/ )
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::CrashReport );
|
||||
item->crashReport.time = Profiler::GetTime();
|
||||
item->crashReport.thread = thread;
|
||||
@ -897,7 +897,7 @@ static void CrashHandler( int signal, siginfo_t* info, void* /*ucontext*/ )
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::Crash );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
@ -1577,7 +1577,7 @@ void Profiler::CompressWorker()
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::FrameImage );
|
||||
MemWrite( &item->frameImage.image, (uint64_t)etc1buf );
|
||||
MemWrite( &item->frameImage.frame, fi->frame );
|
||||
@ -2114,7 +2114,7 @@ void Profiler::CalibrateDelay()
|
||||
{
|
||||
Magic magic;
|
||||
auto& tail = ptoken->get_tail_index();
|
||||
auto item = ptoken->enqueue_begin<moodycamel::CanAlloc>( magic );
|
||||
auto item = ptoken->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBegin );
|
||||
MemWrite( &item->zoneBegin.thread, GetThreadHandle() );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
@ -2130,7 +2130,7 @@ void Profiler::CalibrateDelay()
|
||||
{
|
||||
Magic magic;
|
||||
auto& tail = ptoken->get_tail_index();
|
||||
auto item = ptoken->enqueue_begin<moodycamel::CanAlloc>( magic );
|
||||
auto item = ptoken->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneEnd );
|
||||
MemWrite( &item->zoneEnd.thread, uint64_t( 0 ) );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
@ -2156,7 +2156,7 @@ void Profiler::CalibrateDelay()
|
||||
{
|
||||
Magic magic;
|
||||
auto& tail = ptoken->get_tail_index();
|
||||
auto item = ptoken->enqueue_begin<moodycamel::CanAlloc>( magic );
|
||||
auto item = ptoken->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBegin );
|
||||
MemWrite( &item->zoneBegin.thread, GetThreadHandle() );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
@ -2172,7 +2172,7 @@ void Profiler::CalibrateDelay()
|
||||
{
|
||||
Magic magic;
|
||||
auto& tail = ptoken->get_tail_index();
|
||||
auto item = ptoken->enqueue_begin<moodycamel::CanAlloc>( magic );
|
||||
auto item = ptoken->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneEnd );
|
||||
MemWrite( &item->zoneEnd.thread, uint64_t( 0 ) );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
@ -2222,7 +2222,7 @@ void Profiler::SendCallstack( int depth, uint64_t thread, const char* skipBefore
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::Callstack );
|
||||
MemWrite( &item->callstack.ptr, ptr );
|
||||
MemWrite( &item->callstack.thread, thread );
|
||||
@ -2269,7 +2269,7 @@ void Profiler::ProcessSysTime()
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::SysTimeReport );
|
||||
MemWrite( &item->sysTime.time, GetTime() );
|
||||
MemWrite( &item->sysTime.sysTime, sysTime );
|
||||
@ -2303,7 +2303,7 @@ TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_da
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.thread, thread );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
@ -2314,7 +2314,7 @@ TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_da
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBegin );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime( item->zoneBegin.cpu ) );
|
||||
@ -2348,7 +2348,7 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.thread, thread );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
@ -2359,7 +2359,7 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBeginCallstack );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime( item->zoneBegin.cpu ) );
|
||||
@ -2386,7 +2386,7 @@ void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.thread, thread );
|
||||
tracy::MemWrite( &item->zoneValidation.id, ctx.id );
|
||||
@ -2397,7 +2397,7 @@ void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneEnd );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
tracy::MemWrite( &item->zoneEnd.time, tracy::Profiler::GetTime( item->zoneEnd.cpu ) );
|
||||
@ -2423,7 +2423,7 @@ void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size )
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.thread, thread );
|
||||
tracy::MemWrite( &item->zoneValidation.id, ctx.id );
|
||||
@ -2434,7 +2434,7 @@ void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size )
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneText );
|
||||
tracy::MemWrite( &item->zoneText.thread, thread );
|
||||
tracy::MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
@ -2454,7 +2454,7 @@ void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size )
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.thread, thread );
|
||||
tracy::MemWrite( &item->zoneValidation.id, ctx.id );
|
||||
@ -2465,7 +2465,7 @@ void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size )
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneName );
|
||||
tracy::MemWrite( &item->zoneText.thread, thread );
|
||||
tracy::MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::FrameMarkMsg );
|
||||
MemWrite( &item->frameMark.time, GetTime() );
|
||||
MemWrite( &item->frameMark.name, uint64_t( name ) );
|
||||
@ -212,7 +212,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::PlotData );
|
||||
MemWrite( &item->plotData.name, (uint64_t)name );
|
||||
MemWrite( &item->plotData.time, GetTime() );
|
||||
@ -229,7 +229,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::PlotData );
|
||||
MemWrite( &item->plotData.name, (uint64_t)name );
|
||||
MemWrite( &item->plotData.time, GetTime() );
|
||||
@ -246,7 +246,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::PlotData );
|
||||
MemWrite( &item->plotData.name, (uint64_t)name );
|
||||
MemWrite( &item->plotData.time, GetTime() );
|
||||
@ -267,7 +267,7 @@ public:
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::Message );
|
||||
MemWrite( &item->message.time, GetTime() );
|
||||
MemWrite( &item->message.thread, thread );
|
||||
@ -284,7 +284,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::MessageLiteral );
|
||||
MemWrite( &item->message.time, GetTime() );
|
||||
MemWrite( &item->message.thread, thread );
|
||||
@ -304,7 +304,7 @@ public:
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::MessageColor );
|
||||
MemWrite( &item->messageColor.time, GetTime() );
|
||||
MemWrite( &item->messageColor.thread, thread );
|
||||
@ -324,7 +324,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::MessageLiteralColor );
|
||||
MemWrite( &item->messageColor.time, GetTime() );
|
||||
MemWrite( &item->messageColor.thread, thread );
|
||||
@ -344,7 +344,7 @@ public:
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::MessageAppInfo );
|
||||
MemWrite( &item->message.time, GetTime() );
|
||||
MemWrite( &item->message.thread, thread );
|
||||
@ -430,7 +430,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::Callstack );
|
||||
MemWrite( &item->callstack.ptr, ptr );
|
||||
MemWrite( &item->callstack.thread, thread );
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBegin );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) );
|
||||
@ -55,7 +55,7 @@ public:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBeginCallstack );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) );
|
||||
@ -81,7 +81,7 @@ public:
|
||||
const auto thread = GetThreadHandle();
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneEnd );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
MemWrite( &item->zoneEnd.time, Profiler::GetTime( item->zoneEnd.cpu ) );
|
||||
@ -107,7 +107,7 @@ public:
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneText );
|
||||
MemWrite( &item->zoneText.thread, thread );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
@ -127,7 +127,7 @@ public:
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
auto item = token->enqueue_begin( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneName );
|
||||
MemWrite( &item->zoneText.thread, thread );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
|
@ -245,8 +245,6 @@ namespace details {
|
||||
} max_align_t;
|
||||
}
|
||||
|
||||
enum AllocationMode { CanAlloc, CannotAlloc };
|
||||
|
||||
// Default traits for the ConcurrentQueue. To change some of the
|
||||
// traits without re-implementing all of them, inherit from this
|
||||
// struct and shadow the declarations you wish to be different;
|
||||
@ -870,7 +868,7 @@ public:
|
||||
inline bool enqueue(T const& item)
|
||||
{
|
||||
if (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE == 0) return false;
|
||||
return inner_enqueue<CanAlloc>(item);
|
||||
return inner_enqueue(item);
|
||||
}
|
||||
|
||||
// Enqueues a single item (by moving it, if possible).
|
||||
@ -881,7 +879,7 @@ public:
|
||||
inline bool enqueue(T&& item)
|
||||
{
|
||||
if (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE == 0) return false;
|
||||
return inner_enqueue<CanAlloc>(std::move(item));
|
||||
return inner_enqueue(std::move(item));
|
||||
}
|
||||
|
||||
// Enqueues a single item (by copying it) using an explicit producer token.
|
||||
@ -890,7 +888,7 @@ public:
|
||||
// Thread-safe.
|
||||
inline bool enqueue(producer_token_t const& token, T const& item)
|
||||
{
|
||||
return inner_enqueue<CanAlloc>(token, item);
|
||||
return inner_enqueue(token, item);
|
||||
}
|
||||
|
||||
// Enqueues a single item (by moving it, if possible) using an explicit producer token.
|
||||
@ -899,12 +897,12 @@ public:
|
||||
// Thread-safe.
|
||||
inline bool enqueue(producer_token_t const& token, T&& item)
|
||||
{
|
||||
return inner_enqueue<CanAlloc>(token, std::move(item));
|
||||
return inner_enqueue(token, std::move(item));
|
||||
}
|
||||
|
||||
tracy_force_inline T* enqueue_begin(producer_token_t const& token, index_t& currentTailIndex)
|
||||
{
|
||||
return inner_enqueue_begin<CanAlloc>(token, currentTailIndex);
|
||||
return inner_enqueue_begin(token, currentTailIndex);
|
||||
}
|
||||
|
||||
// Enqueues several items.
|
||||
@ -917,7 +915,7 @@ public:
|
||||
bool enqueue_bulk(It itemFirst, size_t count)
|
||||
{
|
||||
if (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE == 0) return false;
|
||||
return inner_enqueue_bulk<CanAlloc>(itemFirst, count);
|
||||
return inner_enqueue_bulk(itemFirst, count);
|
||||
}
|
||||
|
||||
// Enqueues several items using an explicit producer token.
|
||||
@ -929,7 +927,7 @@ public:
|
||||
template<typename It>
|
||||
bool enqueue_bulk(producer_token_t const& token, It itemFirst, size_t count)
|
||||
{
|
||||
return inner_enqueue_bulk<CanAlloc>(token, itemFirst, count);
|
||||
return inner_enqueue_bulk(token, itemFirst, count);
|
||||
}
|
||||
|
||||
// Enqueues a single item (by copying it).
|
||||
@ -1239,36 +1237,35 @@ private:
|
||||
// Queue methods
|
||||
///////////////////////////////
|
||||
|
||||
template<AllocationMode canAlloc, typename U>
|
||||
template<typename U>
|
||||
inline bool inner_enqueue(producer_token_t const& token, U&& element)
|
||||
{
|
||||
return static_cast<ExplicitProducer*>(token.producer)->ConcurrentQueue::ExplicitProducer::template enqueue<canAlloc>(std::forward<U>(element));
|
||||
return static_cast<ExplicitProducer*>(token.producer)->ConcurrentQueue::ExplicitProducer::template enqueue(std::forward<U>(element));
|
||||
}
|
||||
|
||||
template<AllocationMode canAlloc>
|
||||
tracy_force_inline T* inner_enqueue_begin(producer_token_t const& token, index_t& currentTailIndex)
|
||||
{
|
||||
return static_cast<ExplicitProducer*>(token.producer)->ConcurrentQueue::ExplicitProducer::template enqueue_begin<canAlloc>(currentTailIndex);
|
||||
return static_cast<ExplicitProducer*>(token.producer)->ConcurrentQueue::ExplicitProducer::template enqueue_begin(currentTailIndex);
|
||||
}
|
||||
|
||||
template<AllocationMode canAlloc, typename U>
|
||||
template<typename U>
|
||||
inline bool inner_enqueue(U&& element)
|
||||
{
|
||||
auto producer = get_or_add_implicit_producer();
|
||||
return producer == nullptr ? false : producer->ConcurrentQueue::ImplicitProducer::template enqueue<canAlloc>(std::forward<U>(element));
|
||||
return producer == nullptr ? false : producer->ConcurrentQueue::ImplicitProducer::template enqueue(std::forward<U>(element));
|
||||
}
|
||||
|
||||
template<AllocationMode canAlloc, typename It>
|
||||
template<typename It>
|
||||
inline bool inner_enqueue_bulk(producer_token_t const& token, It itemFirst, size_t count)
|
||||
{
|
||||
return static_cast<ExplicitProducer*>(token.producer)->ConcurrentQueue::ExplicitProducer::template enqueue_bulk<canAlloc>(itemFirst, count);
|
||||
return static_cast<ExplicitProducer*>(token.producer)->ConcurrentQueue::ExplicitProducer::template enqueue_bulk(itemFirst, count);
|
||||
}
|
||||
|
||||
template<AllocationMode canAlloc, typename It>
|
||||
template<typename It>
|
||||
inline bool inner_enqueue_bulk(It itemFirst, size_t count)
|
||||
{
|
||||
auto producer = get_or_add_implicit_producer();
|
||||
return producer == nullptr ? false : producer->ConcurrentQueue::ImplicitProducer::template enqueue_bulk<canAlloc>(itemFirst, count);
|
||||
return producer == nullptr ? false : producer->ConcurrentQueue::ImplicitProducer::template enqueue_bulk(itemFirst, count);
|
||||
}
|
||||
|
||||
inline bool update_current_producer_after_rotation(consumer_token_t& token)
|
||||
@ -1717,7 +1714,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
template<AllocationMode allocMode, typename U>
|
||||
template<typename U>
|
||||
inline bool enqueue(U&& element)
|
||||
{
|
||||
index_t currentTailIndex = this->tailIndex.load(std::memory_order_relaxed);
|
||||
@ -1756,13 +1753,13 @@ private:
|
||||
// to allocate a new index. Note pr_blockIndexRaw can only be nullptr if
|
||||
// the initial allocation failed in the constructor.
|
||||
|
||||
if (allocMode == CannotAlloc || !new_block_index(pr_blockIndexSlotsUsed)) {
|
||||
if (!new_block_index(pr_blockIndexSlotsUsed)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert a new block in the circular linked list
|
||||
auto newBlock = this->parent->ConcurrentQueue::template requisition_block<allocMode>();
|
||||
auto newBlock = this->parent->ConcurrentQueue::template requisition_block();
|
||||
if (newBlock == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@ -1817,7 +1814,6 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
template<AllocationMode allocMode>
|
||||
inline void enqueue_begin_alloc(index_t currentTailIndex)
|
||||
{
|
||||
// We reached the end of a block, start a new one
|
||||
@ -1842,7 +1838,7 @@ private:
|
||||
}
|
||||
|
||||
// Insert a new block in the circular linked list
|
||||
auto newBlock = this->parent->ConcurrentQueue::template requisition_block<allocMode>();
|
||||
auto newBlock = this->parent->ConcurrentQueue::template requisition_block();
|
||||
newBlock->ConcurrentQueue::Block::template reset_empty<explicit_context>();
|
||||
if (this->tailBlock == nullptr) {
|
||||
newBlock->next = newBlock;
|
||||
@ -1863,12 +1859,11 @@ private:
|
||||
pr_blockIndexFront = (pr_blockIndexFront + 1) & (pr_blockIndexSize - 1);
|
||||
}
|
||||
|
||||
template<AllocationMode allocMode>
|
||||
tracy_force_inline T* enqueue_begin(index_t& currentTailIndex)
|
||||
{
|
||||
currentTailIndex = this->tailIndex.load(std::memory_order_relaxed);
|
||||
if (details::cqUnlikely((currentTailIndex & static_cast<index_t>(BLOCK_SIZE - 1)) == 0)) {
|
||||
this->enqueue_begin_alloc<allocMode>(currentTailIndex);
|
||||
this->enqueue_begin_alloc(currentTailIndex);
|
||||
}
|
||||
return (*this->tailBlock)[currentTailIndex];
|
||||
}
|
||||
@ -1977,7 +1972,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
template<AllocationMode allocMode, typename It>
|
||||
template<typename It>
|
||||
bool enqueue_bulk(It itemFirst, size_t count)
|
||||
{
|
||||
// First, we need to make sure we have enough room to enqueue all of the elements;
|
||||
@ -2017,7 +2012,7 @@ private:
|
||||
assert(!details::circular_less_than<index_t>(currentTailIndex, head));
|
||||
bool full = !details::circular_less_than<index_t>(head, currentTailIndex + BLOCK_SIZE) || (MAX_SUBQUEUE_SIZE != details::const_numeric_max<size_t>::value && (MAX_SUBQUEUE_SIZE == 0 || MAX_SUBQUEUE_SIZE - BLOCK_SIZE < currentTailIndex - head));
|
||||
if (pr_blockIndexRaw == nullptr || pr_blockIndexSlotsUsed == pr_blockIndexSize || full) {
|
||||
if (allocMode == CannotAlloc || full || !new_block_index(originalBlockIndexSlotsUsed)) {
|
||||
if (full || !new_block_index(originalBlockIndexSlotsUsed)) {
|
||||
// Failed to allocate, undo changes (but keep injected blocks)
|
||||
pr_blockIndexFront = originalBlockIndexFront;
|
||||
pr_blockIndexSlotsUsed = originalBlockIndexSlotsUsed;
|
||||
@ -2032,7 +2027,7 @@ private:
|
||||
}
|
||||
|
||||
// Insert a new block in the circular linked list
|
||||
auto newBlock = this->parent->ConcurrentQueue::template requisition_block<allocMode>();
|
||||
auto newBlock = this->parent->ConcurrentQueue::template requisition_block();
|
||||
if (newBlock == nullptr) {
|
||||
pr_blockIndexFront = originalBlockIndexFront;
|
||||
pr_blockIndexSlotsUsed = originalBlockIndexSlotsUsed;
|
||||
@ -2363,7 +2358,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
template<AllocationMode allocMode, typename U>
|
||||
template<typename U>
|
||||
inline bool enqueue(U&& element)
|
||||
{
|
||||
index_t currentTailIndex = this->tailIndex.load(std::memory_order_relaxed);
|
||||
@ -2377,12 +2372,12 @@ private:
|
||||
}
|
||||
// Find out where we'll be inserting this block in the block index
|
||||
BlockIndexEntry* idxEntry;
|
||||
if (!insert_block_index_entry<allocMode>(idxEntry, currentTailIndex)) {
|
||||
if (!insert_block_index_entry(idxEntry, currentTailIndex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get ahold of a new block
|
||||
auto newBlock = this->parent->ConcurrentQueue::template requisition_block<allocMode>();
|
||||
auto newBlock = this->parent->ConcurrentQueue::template requisition_block();
|
||||
if (newBlock == nullptr) {
|
||||
rewind_block_index_tail();
|
||||
idxEntry->value.store(nullptr, std::memory_order_relaxed);
|
||||
@ -2485,7 +2480,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
template<AllocationMode allocMode, typename It>
|
||||
template<typename It>
|
||||
bool enqueue_bulk(It itemFirst, size_t count)
|
||||
{
|
||||
// First, we need to make sure we have enough room to enqueue all of the elements;
|
||||
@ -2517,7 +2512,7 @@ private:
|
||||
auto head = this->headIndex.load(std::memory_order_relaxed);
|
||||
assert(!details::circular_less_than<index_t>(currentTailIndex, head));
|
||||
bool full = !details::circular_less_than<index_t>(head, currentTailIndex + BLOCK_SIZE) || (MAX_SUBQUEUE_SIZE != details::const_numeric_max<size_t>::value && (MAX_SUBQUEUE_SIZE == 0 || MAX_SUBQUEUE_SIZE - BLOCK_SIZE < currentTailIndex - head));
|
||||
if (full || !(indexInserted = insert_block_index_entry<allocMode>(idxEntry, currentTailIndex)) || (newBlock = this->parent->ConcurrentQueue::template requisition_block<allocMode>()) == nullptr) {
|
||||
if (full || !(indexInserted = insert_block_index_entry(idxEntry, currentTailIndex)) || (newBlock = this->parent->ConcurrentQueue::template requisition_block()) == nullptr) {
|
||||
// Index allocation or block allocation failed; revert any other allocations
|
||||
// and index insertions done so far for this operation
|
||||
if (indexInserted) {
|
||||
@ -2745,7 +2740,6 @@ private:
|
||||
BlockIndexHeader* prev;
|
||||
};
|
||||
|
||||
template<AllocationMode allocMode>
|
||||
inline bool insert_block_index_entry(BlockIndexEntry*& idxEntry, index_t blockStartIndex)
|
||||
{
|
||||
auto localBlockIndex = blockIndex.load(std::memory_order_relaxed); // We're the only writer thread, relaxed is OK
|
||||
@ -2763,7 +2757,7 @@ private:
|
||||
}
|
||||
|
||||
// No room in the old block index, try to allocate another one!
|
||||
if (allocMode == CannotAlloc || !new_block_index()) {
|
||||
if (!new_block_index()) {
|
||||
return false;
|
||||
}
|
||||
localBlockIndex = blockIndex.load(std::memory_order_relaxed);
|
||||
@ -2911,7 +2905,6 @@ private:
|
||||
}
|
||||
|
||||
// Gets a free block from one of the memory pools, or allocates a new one (if applicable)
|
||||
template<AllocationMode canAlloc>
|
||||
Block* requisition_block()
|
||||
{
|
||||
auto block = try_get_block_from_initial_pool();
|
||||
|
@ -306,7 +306,7 @@ To add an item to the queue a specific code pattern is required:
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>(magic);
|
||||
auto item = token->enqueue_begin(magic);
|
||||
// Fill item
|
||||
tail.store(magic+1, std::memory_order_release);
|
||||
\end{lstlisting}
|
||||
|
Loading…
Reference in New Issue
Block a user