Tools/vmap_assembler: Multithread building vmaps

(cherry picked from commit 11a252e601)
This commit is contained in:
Shauren
2024-07-06 12:56:59 +02:00
committed by Ovahlord
parent e46cad36d2
commit f40c4e3218
4 changed files with 92 additions and 48 deletions

View File

@@ -24,6 +24,7 @@
#include <boost/program_options.hpp>
#include <iostream>
#include <string>
#include <thread>
namespace po = boost::program_options;
@@ -34,9 +35,10 @@ namespace po = boost::program_options;
* @param [in] argv raw command line arguments
* @param [out] src raw data dir
* @param [out] dest vmap dest dir
* @param [out] threads number of threads to use
* @return Non-empty optional if program should exit immediately (holds exit code in that case)
*/
Optional<int> HandleArgs(int argc, char* argv[], std::string* src, std::string* dest);
Optional<int> HandleArgs(int argc, char* argv[], std::string* src, std::string* dest, uint32* threads);
int main(int argc, char* argv[])
{
@@ -45,14 +47,15 @@ int main(int argc, char* argv[])
Trinity::Locale::Init();
std::string src, dest;
if (Optional<int> exitCode = HandleArgs(argc, argv, &src, &dest))
uint32 threads = 0;
if (Optional<int> exitCode = HandleArgs(argc, argv, &src, &dest, &threads))
return *exitCode;
Trinity::Banner::Show("VMAP assembler", [](char const* text) { std::cout << text << std::endl; }, nullptr);
std::cout << "using " << src << " as source directory and writing output to " << dest << std::endl;
VMAP::TileAssembler ta(std::move(src), std::move(dest));
VMAP::TileAssembler ta(std::move(src), std::move(dest), threads);
if (!ta.convertWorld2())
{
@@ -64,10 +67,11 @@ int main(int argc, char* argv[])
return 0;
}
Optional<int> HandleArgs(int argc, char* argv[], std::string* src, std::string* dest)
Optional<int> HandleArgs(int argc, char* argv[], std::string* src, std::string* dest, uint32* threads)
{
po::options_description visible("Usage: vmap4assembler [OPTION]... [SRC] [DEST]\n\nWhere OPTION can be any of");
visible.add_options()
("threads", po::value<uint32>(threads)->default_value(std::thread::hardware_concurrency()), "number of threads to use")
("help,h", "print usage message")
("version,v", "print version build info");