A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
refactor(f1): drop Log sink mutex (web is single-threaded)
esengine2195677f095a
diff --git a/src/esengine/core/Log.cpp b/src/esengine/core/Log.cppindex d14969300..1873cd475 100644--- a/src/esengine/core/Log.cpp+++ b/src/esengine/core/Log.cpp@@ -19,9 +19,6 @@ namespace esengine {LogLevel Log::level_ = LogLevel::Info;std::vector<std::pair<u32, LogSink>> Log::sinks_;-#ifndef ES_PLATFORM_WEB-std::mutex Log::sinkMutex_;-#endifu32 Log::nextSinkId_ = 1;void Log::init() {@@ -58,18 +55,12 @@ const char* Log::levelToString(LogLevel level) {}u32 Log::addSink(LogSink sink) {-#ifndef ES_PLATFORM_WEB- std::lock_guard<std::mutex> lock(sinkMutex_);-#endifu32 id = nextSinkId_++;sinks_.emplace_back(id, std::move(sink));return id;}void Log::removeSink(u32 sinkId) {-#ifndef ES_PLATFORM_WEB- std::lock_guard<std::mutex> lock(sinkMutex_);-#endifsinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(),[sinkId](const auto& pair) { return pair.first == sinkId; }),@@ -77,10 +68,6 @@ void Log::removeSink(u32 sinkId) {}void Log::notifySinks(LogLevel level, const std::string& message) {-#ifndef ES_PLATFORM_WEB- std::lock_guard<std::mutex> lock(sinkMutex_);-#endif-auto now = std::chrono::system_clock::now();auto duration = now.time_since_epoch();auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();diff --git a/src/esengine/core/Log.hpp b/src/esengine/core/Log.hppindex ee6dc2a96..e6c7b8d40 100644--- a/src/esengine/core/Log.hpp+++ b/src/esengine/core/Log.hpp@@ -23,9 +23,6 @@#include <functional>#include <iomanip>#include <iostream>-#ifndef ES_PLATFORM_WEB-#include <mutex>-#endif#include <sstream>#include <string>#include <vector>@@ -187,9 +184,6 @@ public:private:static LogLevel level_;static std::vector<std::pair<u32, LogSink>> sinks_;-#ifndef ES_PLATFORM_WEB- static std::mutex sinkMutex_;-#endifstatic u32 nextSinkId_;template<typename... Args>