mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
LogWidget: Use FixedSizeQueue for a log messages buffer
Messages buffer is intended to be of a fixed capacity (MAX_LOG_LINES), which cannot be achieved by std::queue unless we manually pop() extra elements. std::queue uses std::deque internally which most likely results in allocations performed continuously. FixedSizeQueue keeps a single buffer during its entire lifetime, avoiding any allocations except the ones performed by stored objects.
This commit is contained in:
@ -7,9 +7,9 @@
|
||||
#include <QDockWidget>
|
||||
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
|
||||
#include "Common/FixedSizeQueue.h"
|
||||
#include "Common/Logging/LogManager.h"
|
||||
|
||||
class QCheckBox;
|
||||
@ -49,6 +49,9 @@ private:
|
||||
|
||||
using LogEntry = std::pair<std::string, LogTypes::LOG_LEVELS>;
|
||||
|
||||
// Maximum number of lines to show in log viewer
|
||||
static constexpr int MAX_LOG_LINES = 5000;
|
||||
|
||||
std::mutex m_log_mutex;
|
||||
std::queue<LogEntry> m_log_queue;
|
||||
FixedSizeQueue<LogEntry, MAX_LOG_LINES> m_log_ring_buffer;
|
||||
};
|
||||
|
Reference in New Issue
Block a user