Fix C# profiler events from other threads

This commit is contained in:
Wojtek Figat
2021-06-12 20:10:16 +02:00
parent 93cdb7ce8f
commit 25c00a0d55
3 changed files with 29 additions and 16 deletions

View File

@@ -122,6 +122,14 @@ void ProfilerCPU::Thread::EndEvent(int32 index)
e.End = time;
}
void ProfilerCPU::Thread::EndEvent()
{
const double time = Platform::GetTimeSeconds() * 1000.0;
_depth--;
Event& e = Buffer.Get(Buffer.GetCount() - 1);
e.End = time;
}
bool ProfilerCPU::IsProfilingCurrentThread()
{
return Enabled && Thread::Current != nullptr;
@@ -194,11 +202,14 @@ int32 ProfilerCPU::BeginEvent(const char* name)
void ProfilerCPU::EndEvent(int32 index)
{
if (!Enabled)
return;
if (Enabled && Thread::Current)
Thread::Current->EndEvent(index);
}
ASSERT(Thread::Current);
Thread::Current->EndEvent(index);
void ProfilerCPU::EndEvent()
{
if (Enabled && Thread::Current)
Thread::Current->EndEvent();
}
void ProfilerCPU::Dispose()