[READ-ONLY] Mirror of https://github.com/mrgnw/avify.
0

Configure Feed

Select the types of activity you want to include in your feed.

fix sequential ordering: use atomic counter instead of par_iter split

Rayon's par_iter recursively halves the range, so with_min_len(1)
still produces non-sequential starts. Now threads pull from a
shared atomic counter, so files start in order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+21 -15
+21 -15
src/main.rs
··· 6 6 use std::fs; 7 7 use std::io::{self, Write}; 8 8 use std::path::{Path, PathBuf}; 9 + use std::sync::atomic::AtomicUsize; 9 10 use std::sync::Mutex; 10 11 11 12 #[derive(Parser)] ··· 253 254 } 254 255 255 256 let progress = Mutex::new(Progress::new(&args.files)); 257 + let next = AtomicUsize::new(0); 256 258 257 - let result: Result<()> = args 258 - .files 259 - .par_iter() 260 - .with_min_len(1) 261 - .enumerate() 262 - .try_for_each(|(idx, path)| { 263 - process_file( 264 - idx, 265 - path, 266 - args.quality, 267 - args.speed, 268 - args.outdir.as_deref(), 269 - args.move_originals.as_deref(), 270 - &progress, 271 - ) 259 + let result: Result<()> = (0..rayon::current_num_threads()) 260 + .into_par_iter() 261 + .try_for_each(|_| -> Result<()> { 262 + loop { 263 + let idx = next.fetch_add(1, std::sync::atomic::Ordering::SeqCst); 264 + if idx >= args.files.len() { 265 + break; 266 + } 267 + process_file( 268 + idx, 269 + &args.files[idx], 270 + args.quality, 271 + args.speed, 272 + args.outdir.as_deref(), 273 + args.move_originals.as_deref(), 274 + &progress, 275 + )?; 276 + } 277 + Ok(()) 272 278 }); 273 279 274 280 {