forked from StrafesNET/asset-tool
pray rayon doesn't spawn 600 threads and crash
This commit is contained in:
parent
c2041b33e4
commit
cef0f38482
20
src/main.rs
20
src/main.rs
@ -648,17 +648,17 @@ async fn write_files(config:WriteConfig,mut context:DecompiledContext)->AResult<
|
|||||||
}
|
}
|
||||||
|
|
||||||
//run the async
|
//run the async
|
||||||
std::thread::scope(|s|{
|
{
|
||||||
let threads:Vec<std::thread::ScopedJoinHandle<'_,AResult<()>>>=write_queue.into_iter().map(|(write_path,node,node_name_override)|
|
let dom=&context.dom;
|
||||||
s.spawn(||write_item(&context.dom,write_path,node,node_name_override,config.write_models,config.write_scripts))
|
let write_models=config.write_models;
|
||||||
).collect();
|
let write_scripts=config.write_scripts;
|
||||||
for thread in threads{
|
let results:Vec<AResult<()>>=rayon::iter::ParallelIterator::collect(rayon::iter::ParallelIterator::map(rayon::iter::IntoParallelIterator::into_par_iter(write_queue),|(write_path,node,node_name_override)|{
|
||||||
match thread.join(){
|
write_item(&dom,write_path,node,node_name_override,write_models,write_scripts)
|
||||||
Ok(_)=>(),
|
}));
|
||||||
Err(e)=>println!("thread error: {:?}",e),
|
for result in results{
|
||||||
}
|
result?;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
//run the destroy
|
//run the destroy
|
||||||
for destroy_ref in destroy_queue{
|
for destroy_ref in destroy_queue{
|
||||||
|
Loading…
Reference in New Issue
Block a user