mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-12 09:59:05 +02:00
minedmap: add support for parallel processing
For now, only RegionProcessor and TileMipmapper are run in parallel.
This commit is contained in:
parent
c1260a63b5
commit
78fe1ec50e
6 changed files with 191 additions and 11 deletions
|
@ -7,7 +7,7 @@ mod tile_renderer;
|
|||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{Context, Result};
|
||||
use clap::Parser;
|
||||
|
||||
use common::Config;
|
||||
|
@ -18,15 +18,30 @@ use tile_renderer::TileRenderer;
|
|||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
/// Number of parallel threads to use for processing
|
||||
///
|
||||
/// If not given, only a single thread is used. Pass 0 to
|
||||
/// use one thread per logical CPU core.
|
||||
#[arg(short, long)]
|
||||
pub jobs: Option<usize>,
|
||||
/// Minecraft save directory
|
||||
pub input_dir: PathBuf,
|
||||
/// MinedMap data directory
|
||||
pub output_dir: PathBuf,
|
||||
}
|
||||
|
||||
fn setup_threads(num_threads: usize) -> Result<()> {
|
||||
rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(num_threads)
|
||||
.build_global()
|
||||
.context("Failed to configure thread pool")
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
let config = Config::new(args);
|
||||
let config = Config::new(&args);
|
||||
|
||||
setup_threads(config.num_threads)?;
|
||||
|
||||
let regions = RegionProcessor::new(&config).run()?;
|
||||
TileRenderer::new(&config).run(®ions)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue