Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/MapGenerator.h
Show All 14 Lines | |||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#ifndef INCLUDED_MAPGENERATOR | #ifndef INCLUDED_MAPGENERATOR | ||||
#define INCLUDED_MAPGENERATOR | #define INCLUDED_MAPGENERATOR | ||||
#include "lib/posix/posix_pthread.h" | #include "lib/posix/posix_pthread.h" | ||||
#include "ps/FileIo.h" | #include "ps/FileIo.h" | ||||
#include "ps/Future.h" | |||||
#include "ps/TemplateLoader.h" | #include "ps/TemplateLoader.h" | ||||
#include "scriptinterface/StructuredClone.h" | #include "scriptinterface/StructuredClone.h" | ||||
wraitii: Need to change this to FutureForward | |||||
#include <boost/random/linear_congruential.hpp> | #include <boost/random/linear_congruential.hpp> | ||||
#include <mutex> | #include <mutex> | ||||
#include <set> | #include <set> | ||||
#include <string> | #include <string> | ||||
#include <thread> | |||||
class CMapGeneratorWorker; | class CMapGeneratorWorker; | ||||
/** | /** | ||||
* Random map generator interface. Initialized by CMapReader and then checked | * Random map generator interface. Initialized by CMapReader and then checked | ||||
* periodically during loading, until it's finished (progress value is 0). | * periodically during loading, until it's finished (progress value is 0). | ||||
* | * | ||||
* The actual work is performed by CMapGeneratorWorker in a separate thread. | * The actual work is performed by CMapGeneratorWorker in a separate thread. | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | private: | ||||
std::vector<std::string> FindTemplates(const std::string& path, bool includeSubdirectories); | std::vector<std::string> FindTemplates(const std::string& path, bool includeSubdirectories); | ||||
/** | /** | ||||
* Returns all template names of actors. | * Returns all template names of actors. | ||||
*/ | */ | ||||
std::vector<std::string> FindActorTemplates(const std::string& path, bool includeSubdirectories); | std::vector<std::string> FindActorTemplates(const std::string& path, bool includeSubdirectories); | ||||
/** | /** | ||||
* Perform map generation in an independent thread. | |||||
*/ | |||||
static void RunThread(CMapGeneratorWorker* self); | |||||
/** | |||||
* Perform the map generation. | * Perform the map generation. | ||||
*/ | */ | ||||
bool Run(); | bool Run(); | ||||
/** | /** | ||||
* Currently loaded script librarynames. | * Currently loaded script librarynames. | ||||
*/ | */ | ||||
std::set<VfsPath> m_LoadedLibraries; | std::set<VfsPath> m_LoadedLibraries; | ||||
Show All 29 Lines | private: | ||||
std::string m_Settings; | std::string m_Settings; | ||||
/** | /** | ||||
* Backend to loading template data. | * Backend to loading template data. | ||||
*/ | */ | ||||
CTemplateLoader m_TemplateLoader; | CTemplateLoader m_TemplateLoader; | ||||
/** | /** | ||||
* Holds the mapgeneration thread identifier. | * Holds the completion result of the asynchronous map generation. | ||||
* TODO: this whole class could really be a future on its own. | |||||
*/ | */ | ||||
std::thread m_WorkerThread; | Future<void> m_WorkerThread; | ||||
/** | /** | ||||
* Avoids thread synchronization issues. | * Avoids thread synchronization issues. | ||||
*/ | */ | ||||
std::mutex m_WorkerMutex; | std::mutex m_WorkerMutex; | ||||
}; | }; | ||||
#endif //INCLUDED_MAPGENERATOR | #endif //INCLUDED_MAPGENERATOR |
Wildfire Games · Phabricator
Need to change this to FutureForward