From 9086231f3923c0df6d9ef817441bfae5e134e8ff Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 12:07:03 +0100 Subject: Converted use of _format UDL to fmt::format --- zenserver/zenserver.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'zenserver/zenserver.cpp') diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 6e5d2fe93..40d40e908 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -114,7 +114,6 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { using namespace std::literals; -using namespace fmt::literals; namespace utils { asio::error_code ResolveHostname(asio::io_context& Ctx, @@ -139,7 +138,7 @@ namespace utils { { for (const asio::ip::tcp::endpoint Ep : Endpoints) { - OutEndpoints.push_back("http://{}:{}"_format(Ep.address().to_string(), Ep.port())); + OutEndpoints.push_back(fmt::format("http://{}:{}", Ep.address().to_string(), Ep.port())); } } @@ -152,8 +151,6 @@ class ZenServer : public IHttpStatusProvider public: void Initialize(const ZenServerOptions& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry) { - using namespace fmt::literals; - m_ServerEntry = ServerEntry; m_DebugOptionForcedCrash = ServerOptions.ShouldCrash; const int ParentPid = ServerOptions.OwnerPid; @@ -180,11 +177,11 @@ public: // Initialize/check mutex based on base port - std::string MutexName = "zen_{}"_format(ServerOptions.BasePort); + std::string MutexName = fmt::format("zen_{}", ServerOptions.BasePort); if (zen::NamedMutex::Exists(MutexName) || ((m_ServerMutex.Create(MutexName) == false))) { - throw std::runtime_error("Failed to create mutex '{}' - is another instance already running?"_format(MutexName).c_str()); + throw std::runtime_error(fmt::format("Failed to create mutex '{}' - is another instance already running?", MutexName).c_str()); } InitializeState(ServerOptions); @@ -585,7 +582,7 @@ ZenServer::InitializeState(const ZenServerOptions& ServerOptions) else { WipeState = true; - WipeReason = "No manifest present at '{}'"_format(ManifestPath); + WipeReason = fmt::format("No manifest present at '{}'", ManifestPath); } } else @@ -598,7 +595,7 @@ ZenServer::InitializeState(const ZenServerOptions& ServerOptions) ZEN_ERROR("Manifest validation failed: {}, state will be wiped", ValidationResult); WipeState = true; - WipeReason = "Validation of manifest at '{}' failed: {}"_format(ManifestPath, ValidationResult); + WipeReason = fmt::format("Validation of manifest at '{}' failed: {}", ManifestPath, ValidationResult); } else { @@ -609,7 +606,7 @@ ZenServer::InitializeState(const ZenServerOptions& ServerOptions) if (ManifestVersion != ZEN_CFG_SCHEMA_VERSION) { WipeState = true; - WipeReason = "Manifest schema version: {}, differs from required: {}"_format(ManifestVersion, ZEN_CFG_SCHEMA_VERSION); + WipeReason = fmt::format("Manifest schema version: {}, differs from required: {}", ManifestVersion, ZEN_CFG_SCHEMA_VERSION); } } } -- cgit v1.2.3 From e3af18b307416437a31ba3e8c4a4fad19ea735d4 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 13:45:36 +0100 Subject: Moving a temporary prevents copy elision optimization --- zenserver/zenserver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zenserver/zenserver.cpp') diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 40d40e908..f96fccdac 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -386,7 +386,7 @@ public: { if (!m_IoRunner.joinable()) { - m_IoRunner = std::move(std::jthread{[this] { m_IoContext.run(); }}); + m_IoRunner = std::jthread{[this] { m_IoContext.run(); }}; } } -- cgit v1.2.3 From fe3225e42c316581fa66d482bfe5a406299f4305 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 13:46:22 +0100 Subject: std::jthread is not supported on Apple Clang --- zenserver/zenserver.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'zenserver/zenserver.cpp') diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index f96fccdac..8fb91c890 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -361,6 +361,7 @@ public: ZEN_INFO(ZEN_APP_NAME " exiting"); m_IoContext.stop(); + m_IoRunner.join(); Flush(); } @@ -386,7 +387,7 @@ public: { if (!m_IoRunner.joinable()) { - m_IoRunner = std::jthread{[this] { m_IoContext.run(); }}; + m_IoRunner = std::thread{[this] { m_IoContext.run(); }}; } } @@ -482,7 +483,7 @@ private: CbObject m_RootManifest; std::filesystem::path m_DataRoot; std::filesystem::path m_ContentRoot; - std::jthread m_IoRunner; + std::thread m_IoRunner; asio::io_context m_IoContext; asio::steady_timer m_PidCheckTimer{m_IoContext}; zen::ProcessMonitor m_ProcessMonitor; -- cgit v1.2.3 From 7a1f88278a58dbe56786e57ed82eb4efa731fddd Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 13:54:18 +0100 Subject: Apple Clang issues fmt::format compile errors for enum class-type args --- zenserver/zenserver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zenserver/zenserver.cpp') diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 8fb91c890..08b3d6c05 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -593,10 +593,10 @@ ZenServer::InitializeState(const ZenServerOptions& ServerOptions) if (CbValidateError ValidationResult = ValidateCompactBinary(Manifest, CbValidateMode::All); ValidationResult != CbValidateError::None) { - ZEN_ERROR("Manifest validation failed: {}, state will be wiped", ValidationResult); + ZEN_ERROR("Manifest validation failed: {}, state will be wiped", uint32_t(ValidationResult)); WipeState = true; - WipeReason = fmt::format("Validation of manifest at '{}' failed: {}", ManifestPath, ValidationResult); + WipeReason = fmt::format("Validation of manifest at '{}' failed: {}", ManifestPath, uint32_t(ValidationResult)); } else { -- cgit v1.2.3