ddnet/src/engine/server/server_logger.h
Robert Müller 10470046b7 Use CLock instead of std::mutex, add thread-safety annotations
Use `CLock` and `CLockScope` instead of `std::mutex` and add clang thread-safety analysis annotations everywhere except for usages in engine graphics and video, as those usages also involve `std::condition_variable`.

Fix lock not being unlocked on all code paths in `CFutureLogger::Log`, which is caught by the static analysis.
2023-11-11 00:09:17 +01:00

24 lines
526 B
C++

#ifndef ENGINE_SERVER_SERVER_LOGGER_H
#define ENGINE_SERVER_SERVER_LOGGER_H
#include <base/logger.h>
#include <thread>
class CServer;
class CServerLogger : public ILogger
{
CServer *m_pServer = nullptr;
CLock m_PendingLock;
std::vector<CLogMessage> m_vPending;
std::thread::id m_MainThread;
public:
CServerLogger(CServer *pServer);
void Log(const CLogMessage *pMessage) override REQUIRES(!m_PendingLock);
// Must be called from the main thread!
void OnServerDeletion();
};
#endif // ENGINE_SERVER_SERVER_LOGGER_H