mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-20 07:00:30 +00:00
Add ScopedTimer, Remove some comments
This commit is contained in:
19
include/TScopedTimer.h
Normal file
19
include/TScopedTimer.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class TScopedTimer {
|
||||
public:
|
||||
TScopedTimer();
|
||||
TScopedTimer(const std::string& Name);
|
||||
TScopedTimer(std::function<void(size_t)> OnDestroy);
|
||||
~TScopedTimer();
|
||||
|
||||
std::function<void(size_t /* time_ms */)> OnDestroy { nullptr };
|
||||
|
||||
private:
|
||||
std::chrono::high_resolution_clock::time_point mStartTime;
|
||||
std::string Name;
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "IThreaded.h"
|
||||
#include "RWMutex.h"
|
||||
#include "TScopedTimer.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -27,6 +28,7 @@ public:
|
||||
static void GlobalParser(const std::weak_ptr<TClient>& Client, std::string Packet, TPPSMonitor& PPSMonitor, TNetwork& Network);
|
||||
static void HandleEvent(TClient& c, const std::string& Data);
|
||||
RWMutex& GetClientMutex() const { return mClientsMutex; }
|
||||
|
||||
private:
|
||||
TClientSet mClients;
|
||||
mutable RWMutex mClientsMutex;
|
||||
@@ -34,4 +36,5 @@ private:
|
||||
static bool ShouldSpawn(TClient& c, const std::string& CarJson, int ID);
|
||||
static bool IsUnicycle(TClient& c, const std::string& CarJson);
|
||||
static void Apply(TClient& c, int VID, const std::string& pckt);
|
||||
TScopedTimer mLifeTimer { "Server" };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user