diff options
author | Mattes D <github@xoft.cz> | 2014-10-30 12:22:15 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-10-30 12:22:15 +0100 |
commit | 30db6d9852e7dc4ba5f7d4a9d783ae8a6d4c4f79 (patch) | |
tree | 574b3c572b0b06e1733f4854fd46ca20147ab575 /Tools/QtBiomeVisualiser/ChunkSource.h | |
parent | Merge pull request #1575 from mc-server/1.8-Item (diff) | |
parent | QtBiomeVisualiser: Generator uses all machine threads. (diff) | |
download | cuberite-30db6d9852e7dc4ba5f7d4a9d783ae8a6d4c4f79.tar cuberite-30db6d9852e7dc4ba5f7d4a9d783ae8a6d4c4f79.tar.gz cuberite-30db6d9852e7dc4ba5f7d4a9d783ae8a6d4c4f79.tar.bz2 cuberite-30db6d9852e7dc4ba5f7d4a9d783ae8a6d4c4f79.tar.lz cuberite-30db6d9852e7dc4ba5f7d4a9d783ae8a6d4c4f79.tar.xz cuberite-30db6d9852e7dc4ba5f7d4a9d783ae8a6d4c4f79.tar.zst cuberite-30db6d9852e7dc4ba5f7d4a9d783ae8a6d4c4f79.zip |
Diffstat (limited to 'Tools/QtBiomeVisualiser/ChunkSource.h')
-rw-r--r-- | Tools/QtBiomeVisualiser/ChunkSource.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Tools/QtBiomeVisualiser/ChunkSource.h b/Tools/QtBiomeVisualiser/ChunkSource.h index a6bc3849b..62f9b5626 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.h +++ b/Tools/QtBiomeVisualiser/ChunkSource.h @@ -53,10 +53,30 @@ protected: cIniFilePtr m_IniFile; /** The generator used for generating biomes. */ - cBiomeGenPtr m_BiomeGen; + std::vector<cBiomeGenPtr> m_BiomeGens; - /** Guards m_BiomeGen against multithreaded access. */ + /** Guards m_BiomeGens against multithreaded access. */ QMutex m_Mtx; + + /** Keeps track of the current settings of the biomegens. + Incremented by one each time reload() is called. Provides the means of releasing old biomegens that were + in use while reload() was being processed and thus couldn't be changed back then. releaseBiomeGen() does + the job of filtering the biogens before reusing them. */ + int m_CurrentTag; + + + /** Retrieves one cBiomeGenPtr from m_BiomeGens. + If there's no biogen available there, creates a new one based on the ini file. + When done with it, the caller should call releaseBiomeGen() to put the biogen back to m_BiomeGens. + a_Tag receives the value of m_CurrentTag from when the lock was held; it should be passed to + releaseBiomeGen() together with the biogen. */ + cBiomeGenPtr getBiomeGen(int & a_Tag); + + /** Marks the specified biogen as available for reuse (puts it back into m_BiomeGens). + a_Tag is the value of m_CurrentTag from the time when the biogen was retrieved; if it is different from + current m_CurrentTagValue, the biogen will be disposed of (because reload() has been called in the + meantime). */ + void releaseBiomeGen(cBiomeGenPtr && a_BiomeGen, int a_Tag); }; |