You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
[FYI] robert.millar Original CL Desc ----------------------------------------------------------------- Version of ProvideTelemetry taking a lambda to avoid calculating some statistics if they aren't necessary. #rb none [CL 26362025 by robert millar in 5.3 branch]
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "TelemetryRouter.h"
|
|
#include "TelemetryUtils.h"
|
|
#include "Misc/ScopeRWLock.h"
|
|
|
|
FTelemetryRouter::FTelemetryRouter()
|
|
{
|
|
}
|
|
|
|
FTelemetryRouter::~FTelemetryRouter()
|
|
{
|
|
}
|
|
|
|
FTelemetryRouter& FTelemetryRouter::Get()
|
|
{
|
|
return FTelemetryUtils::GetRouter();
|
|
}
|
|
|
|
void FTelemetryRouter::ProvideTelemetryInternal(FGuid Key, const void* Data)
|
|
{
|
|
FReadScopeLock Lock(SinkLock);
|
|
TGuardValue Guard(ReentrancyGuard, FPlatformTLS::GetCurrentThreadId());
|
|
TMap<FDelegateHandle, TFunction<bool(const void*)>>* Sinks = KeyToSinks.Find(Key);
|
|
if (Sinks)
|
|
{
|
|
for (auto It = Sinks->CreateIterator(); It; ++It)
|
|
{
|
|
bool bStillBound = It->Value(Data);
|
|
if (!bStillBound)
|
|
{
|
|
It.RemoveCurrent();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void FTelemetryRouter::RegisterTelemetrySinkInternal(FGuid Key, FDelegateHandle InHandle, TFunction<bool(const void*)> Sink)
|
|
{
|
|
FWriteScopeLock Lock(SinkLock);
|
|
TGuardValue Guard(ReentrancyGuard, FPlatformTLS::GetCurrentThreadId());
|
|
TMap<FDelegateHandle, TFunction<bool(const void*)>>& Sinks = KeyToSinks.FindOrAdd(Key);
|
|
Sinks.Add(InHandle, MoveTemp(Sink));
|
|
}
|
|
|
|
void FTelemetryRouter::UnregisterTelemetrySinkInternal(FGuid Key, FDelegateHandle InHandle)
|
|
{
|
|
FWriteScopeLock Lock(SinkLock);
|
|
TGuardValue Guard(ReentrancyGuard, FPlatformTLS::GetCurrentThreadId());
|
|
TMap<FDelegateHandle, TFunction<bool(const void*)>>* Sinks = KeyToSinks.Find(Key);
|
|
if (Sinks)
|
|
{
|
|
Sinks->Remove(InHandle);
|
|
}
|
|
} |