From 20f3cb34aec0cddfe824d9cdc6696cf15b62c28b Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 26 May 2023 13:17:13 +0200 Subject: Anvil: Refactored to use shared_ptr. --- src/WorldStorage/WSSAnvil.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/WorldStorage/WSSAnvil.h') diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 69006ec95..e0c9a9320 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -83,10 +83,13 @@ protected: /** Opens a MCA file either for a Read operation (fails if doesn't exist) or for a Write operation (creates new if not found) */ bool OpenFile(bool a_IsForReading); } ; - typedef std::list cMCAFiles; + /** Protects m_Files against multithreaded access. */ cCriticalSection m_CS; - cMCAFiles m_Files; // a MRU cache of MCA files + + /** A MRU cache of MCA files. + Protected against multithreaded access by m_CS. */ + std::list> m_Files; Compression::Extractor m_Extractor; Compression::Compressor m_Compressor; @@ -291,7 +294,7 @@ protected: bool GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, Vector3i & a_AbsPos); /** Gets the correct MCA file either from cache or from disk, manages the m_MCAFiles cache; assumes m_CS is locked */ - cMCAFile * LoadMCAFile(const cChunkCoords & a_Chunk); + std::shared_ptr LoadMCAFile(const cChunkCoords & a_Chunk); // cWSSchema overrides: virtual bool LoadChunk(const cChunkCoords & a_Chunk) override; -- cgit v1.2.3