Multi Dll Proj will Crash, Under Unity (#244)

This commit is contained in:
JIA-ss 2021-07-25 17:28:42 +08:00 committed by GitHub
parent 06ae39d9cc
commit 5936e7c86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -960,15 +960,17 @@ thread_local bool RpThreadInitDone = false;
# ifdef TRACY_MANUAL_LIFETIME # ifdef TRACY_MANUAL_LIFETIME
ProfilerData* s_profilerData = nullptr; ProfilerData* s_profilerData = nullptr;
static ProfilerThreadData& GetProfilerThreadData();
TRACY_API void StartupProfiler() TRACY_API void StartupProfiler()
{ {
s_profilerData = (ProfilerData*)tracy_malloc( sizeof( ProfilerData ) ); s_profilerData = (ProfilerData*)tracy_malloc( sizeof( ProfilerData ) );
new (s_profilerData) ProfilerData(); new (s_profilerData) ProfilerData();
s_profilerData->profiler.SpawnWorkerThreads(); s_profilerData->profiler.SpawnWorkerThreads();
GetProfilerThreadData().token = ProducerWrapper( *s_profilerData );
} }
static ProfilerData& GetProfilerData() static ProfilerData& GetProfilerData()
{ {
assert(s_profilerData); assert( s_profilerData );
return *s_profilerData; return *s_profilerData;
} }
TRACY_API void ShutdownProfiler() TRACY_API void ShutdownProfiler()
@ -977,6 +979,8 @@ TRACY_API void ShutdownProfiler()
tracy_free( s_profilerData ); tracy_free( s_profilerData );
s_profilerData = nullptr; s_profilerData = nullptr;
rpmalloc_finalize(); rpmalloc_finalize();
RpThreadInitDone = false;
RpInitDone.store( 0, std::memory_order_release );
} }
# else # else
static std::atomic<int> profilerDataLock { 0 }; static std::atomic<int> profilerDataLock { 0 };