diff options
| author | Rochet2 <rochet2@post.com> | 2017-03-17 20:09:58 +0200 |
|---|---|---|
| committer | Aokromes <aokromes@gmail.com> | 2017-08-08 22:52:55 +0200 |
| commit | 0a3e2339ef8763bf4d77b1071619da5ff3469da0 (patch) | |
| tree | a0a2cbad00ea1d02cba930792748c7f37e9dc754 | |
| parent | 4f43f4d72f10cf1f4e522979f1050e5141c226c2 (diff) | |
Tools/MMapsGenerator: Use system supported threads instead of hardcoded amount (#19255)
- Use unsigned int for thread count
- Use std::thread::hardware_concurrency() to try estimate available threads instead of hardcoded 3 threads by default
- Print thread count always regardless of using --threads switch or not
| -rw-r--r-- | src/tools/mmaps_generator/MapBuilder.cpp | 6 | ||||
| -rw-r--r-- | src/tools/mmaps_generator/MapBuilder.h | 2 | ||||
| -rw-r--r-- | src/tools/mmaps_generator/PathGenerator.cpp | 8 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index e7f91507368..df9c1607bd3 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -207,9 +207,11 @@ namespace MMAP } } - void MapBuilder::buildAllMaps(int threads) + void MapBuilder::buildAllMaps(unsigned int threads) { - for (int i = 0; i < threads; ++i) + printf("Using %u threads to extract mmaps\n", threads); + + for (unsigned int i = 0; i < threads; ++i) { _workerThreads.push_back(std::thread(&MapBuilder::WorkerThread, this)); } diff --git a/src/tools/mmaps_generator/MapBuilder.h b/src/tools/mmaps_generator/MapBuilder.h index 4b6e0f2795f..19715cbdea6 100644 --- a/src/tools/mmaps_generator/MapBuilder.h +++ b/src/tools/mmaps_generator/MapBuilder.h @@ -94,7 +94,7 @@ namespace MMAP void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY); // builds list of maps, then builds all of mmap tiles (based on the skip settings) - void buildAllMaps(int threads); + void buildAllMaps(unsigned int threads); void WorkerThread(); diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index 90a77cf4ac3..5970b4de276 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -73,7 +73,7 @@ bool handleArgs(int argc, char** argv, bool &bigBaseUnit, char* &offMeshInputPath, char* &file, - int& threads) + unsigned int& threads) { char* param = nullptr; for (int i = 1; i < argc; ++i) @@ -95,8 +95,7 @@ bool handleArgs(int argc, char** argv, param = argv[++i]; if (!param) return false; - threads = atoi(param); - printf("Using %i threads to extract mmaps\n", threads); + threads = static_cast<unsigned int>(std::max(0, atoi(param))); } else if (strcmp(argv[i], "--file") == 0) { @@ -244,7 +243,8 @@ int main(int argc, char** argv) { Trinity::Banner::Show("MMAP generator", [](char const* text) { printf("%s\n", text); }, nullptr); - int threads = 3, mapnum = -1; + unsigned int threads = std::thread::hardware_concurrency(); + int mapnum = -1; float maxAngle = 70.0f; int tileX = -1, tileY = -1; bool skipLiquid = false, |
