forked from metin-server/m2dev-client-src
Optimize pack file loading
- Add thread-local ZSTD decompression context reuse - Integrate BufferPool for temporary buffers - PackManager auto-uses BufferPool for all GetFile calls - Thread-safe pack loading with mutex
This commit is contained in:
@@ -1,26 +1,34 @@
|
||||
#pragma once
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
|
||||
#include "EterBase/Singleton.h"
|
||||
#include "Pack.h"
|
||||
|
||||
class CBufferPool;
|
||||
|
||||
class CPackManager : public CSingleton<CPackManager>
|
||||
{
|
||||
public:
|
||||
CPackManager() = default;
|
||||
virtual ~CPackManager() = default;
|
||||
CPackManager();
|
||||
virtual ~CPackManager();
|
||||
|
||||
bool AddPack(const std::string& path);
|
||||
bool GetFile(std::string_view path, TPackFile& result);
|
||||
bool GetFileWithPool(std::string_view path, TPackFile& result, CBufferPool* pPool);
|
||||
bool IsExist(std::string_view path) const;
|
||||
|
||||
void SetPackLoadMode() { m_load_from_pack = true; }
|
||||
void SetFileLoadMode() { m_load_from_pack = false; }
|
||||
|
||||
CBufferPool* GetBufferPool() { return m_pBufferPool; }
|
||||
|
||||
private:
|
||||
void NormalizePath(std::string_view in, std::string& out) const;
|
||||
|
||||
private:
|
||||
bool m_load_from_pack = true;
|
||||
TPackFileMap m_entries;
|
||||
CBufferPool* m_pBufferPool;
|
||||
mutable std::mutex m_mutex; // Thread safety for parallel pack loading
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user