mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-08 16:56:08 +00:00
replace all clocks with a generic TimeType
This commit is contained in:
@@ -101,7 +101,7 @@ public:
|
||||
// bytes sent on TCP
|
||||
std::atomic_size_t TcpSent = 0;
|
||||
|
||||
std::chrono::system_clock::time_point ConnectionTime{};
|
||||
TimeType::time_point ConnectionTime{};
|
||||
|
||||
|
||||
private:
|
||||
@@ -127,7 +127,7 @@ private:
|
||||
std::string mRole;
|
||||
std::string mDID;
|
||||
int mID = -1;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> mLastPingTime;
|
||||
std::chrono::time_point<TimeType> mLastPingTime;
|
||||
};
|
||||
|
||||
std::optional<std::weak_ptr<TClient>> GetClient(class TServer& Server, int ID);
|
||||
|
||||
@@ -27,6 +27,10 @@ namespace fs = std::filesystem;
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
using TimeType = std::chrono::system_clock;
|
||||
|
||||
// General
|
||||
constexpr std::string_view StrDebug = "Debug";
|
||||
constexpr std::string_view StrPrivate = "Private";
|
||||
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
}
|
||||
|
||||
static void WaitForAll(std::vector<std::shared_ptr<TLuaResult>>& Results,
|
||||
const std::optional<std::chrono::high_resolution_clock::duration>& Max = std::nullopt);
|
||||
const std::optional<TimeType::duration>& Max = std::nullopt);
|
||||
void ReportErrors(const std::vector<std::shared_ptr<TLuaResult>>& Results);
|
||||
bool HasState(TLuaStateId StateId);
|
||||
[[nodiscard]] std::shared_ptr<TLuaResult> EnqueueScript(TLuaStateId StateID, const TLuaChunk& Script);
|
||||
@@ -260,8 +260,8 @@ private:
|
||||
};
|
||||
|
||||
struct TimedEvent {
|
||||
std::chrono::high_resolution_clock::duration Duration {};
|
||||
std::chrono::high_resolution_clock::time_point LastCompletion {};
|
||||
TimeType::duration Duration {};
|
||||
TimeType::time_point LastCompletion {};
|
||||
std::string EventName;
|
||||
TLuaStateId StateId;
|
||||
CallStrategy Strategy;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
class TScopedTimer {
|
||||
public:
|
||||
TScopedTimer();
|
||||
@@ -11,7 +13,7 @@ public:
|
||||
TScopedTimer(std::function<void(size_t)> OnDestroy);
|
||||
~TScopedTimer();
|
||||
auto GetElapsedTime() const {
|
||||
auto EndTime = std::chrono::system_clock::now();
|
||||
auto EndTime = TimeType::now();
|
||||
auto Delta = EndTime - mStartTime;
|
||||
size_t TimeDelta = Delta / std::chrono::milliseconds(1);
|
||||
return TimeDelta;
|
||||
@@ -20,6 +22,6 @@ public:
|
||||
std::function<void(size_t /* time_ms */)> OnDestroy { nullptr };
|
||||
|
||||
private:
|
||||
std::chrono::system_clock::time_point mStartTime;
|
||||
TimeType::time_point mStartTime;
|
||||
std::string Name;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user