Keep track of rpmalloc thread shutdown state.

This commit is contained in:
Bartosz Taudul 2022-02-14 17:52:33 +01:00
parent 72ae4d2ee4
commit 20680fa6a3
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 5 additions and 0 deletions

View File

@ -1120,6 +1120,7 @@ struct ProfilerThreadData
std::atomic<int> RpInitDone { 0 }; std::atomic<int> RpInitDone { 0 };
std::atomic<int> RpInitLock { 0 }; std::atomic<int> RpInitLock { 0 };
thread_local bool RpThreadInitDone = false; thread_local bool RpThreadInitDone = false;
thread_local bool RpThreadShutdown = false;
# ifdef TRACY_MANUAL_LIFETIME # ifdef TRACY_MANUAL_LIFETIME
ProfilerData* s_profilerData = nullptr; ProfilerData* s_profilerData = nullptr;
@ -1267,6 +1268,7 @@ static InitTimeWrapper init_order(101) s_initTime { SetupHwTimer() };
std::atomic<int> init_order(102) RpInitDone( 0 ); std::atomic<int> init_order(102) RpInitDone( 0 );
std::atomic<int> init_order(102) RpInitLock( 0 ); std::atomic<int> init_order(102) RpInitLock( 0 );
thread_local bool RpThreadInitDone = false; thread_local bool RpThreadInitDone = false;
thread_local bool RpThreadShutdown = false;
moodycamel::ConcurrentQueue<QueueItem> init_order(103) s_queue( QueuePrealloc ); moodycamel::ConcurrentQueue<QueueItem> init_order(103) s_queue( QueuePrealloc );
std::atomic<uint32_t> init_order(104) s_lockCounter( 0 ); std::atomic<uint32_t> init_order(104) s_lockCounter( 0 );
std::atomic<uint8_t> init_order(104) s_gpuCtxCounter( 0 ); std::atomic<uint8_t> init_order(104) s_gpuCtxCounter( 0 );

View File

@ -1638,11 +1638,14 @@ _memory_adjust_size_class(size_t iclass) {
} }
} }
extern thread_local bool RpThreadShutdown;
static void static void
_memory_heap_finalize(void* heapptr) { _memory_heap_finalize(void* heapptr) {
heap_t* heap = (heap_t*)heapptr; heap_t* heap = (heap_t*)heapptr;
if (!heap) if (!heap)
return; return;
RpThreadShutdown = true;
//Release thread cache spans back to global cache //Release thread cache spans back to global cache
#if ENABLE_THREAD_CACHE #if ENABLE_THREAD_CACHE
_memory_heap_cache_adopt_deferred(heap); _memory_heap_cache_adopt_deferred(heap);