Move implementation to .cpp

dependabot/npm_and_yarn/Src/WebController/UI/websocket-extensions-0.1.4
Grzegorz Rychlik 2019-11-25 12:27:30 +01:00
parent 686bbdeb9c
commit 89aa4dde63
3 changed files with 21 additions and 16 deletions

View File

@ -173,8 +173,7 @@ void MWR::C3::Core::GateRelay::RunApiBrige(std::string_view apiBrigdeIp, std::ui
{
// Read socket.
std::this_thread::sleep_for(300ms);
auto newSnapshot = sp.GetSnapshotIfChanged();
if (newSnapshot)
if (auto newSnapshot = sp.GetSnapshotIfChanged())
{
try
{

View File

@ -1530,3 +1530,21 @@ json MWR::C3::Core::Profiler::Channel::CreateProfileSnapshot() const
return profile;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MWR::C3::Core::Profiler::SnapshotProxy::SnapshotProxy(Profiler& profiler) :
m_Profiler(profiler)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::optional<MWR::json> MWR::C3::Core::Profiler::SnapshotProxy::GetSnapshotIfChanged()
{
auto currentSnapshot = m_Profiler.Get().m_Gateway.CreateProfileSnapshot();
auto currentHash = std::hash<json>{}(currentSnapshot);
if (previousHash && currentHash == *previousHash)
return {};
previousHash = currentHash;
return currentSnapshot;
}

View File

@ -542,23 +542,11 @@ namespace MWR::C3::Core
public:
/// Create a snapshot proxy
/// @param profiler to wrap CreateProfileShnapshot calls
SnapshotProxy(Profiler& profiler) :
m_Profiler(profiler)
{
}
SnapshotProxy(Profiler& profiler);
/// Create a snapshot
/// @return std::nullopt if snaphot hasn't change since the last call
std::optional<json> GetSnapshotIfChanged()
{
auto currentSnapshot = m_Profiler.Get().m_Gateway.CreateProfileSnapshot();
auto currentHash = std::hash<json>{}(currentSnapshot);
if (previousHash && currentHash == *previousHash)
return {};
previousHash = currentHash;
return currentSnapshot;
}
std::optional<json> GetSnapshotIfChanged();
private:
/// Proxied profiler