pub struct ConcurrentRunner<Config> { /* private fields */ }Expand description
A runner to process files concurrently.
Implementations§
Source§impl<Config: 'static + Send + Sync> ConcurrentRunner<Config>
impl<Config: 'static + Send + Sync> ConcurrentRunner<Config>
Sourcepub fn new<ProcFiles>(num_jobs: usize, proc_files: ProcFiles) -> Self
pub fn new<ProcFiles>(num_jobs: usize, proc_files: ProcFiles) -> Self
Creates a new ConcurrentRunner.
num_jobs- Number of jobs utilized to process files concurrently.proc_files- Function that processes each file found during the search.
Sourcepub fn set_proc_dir_paths<ProcDirPaths>(
self,
proc_dir_paths: ProcDirPaths,
) -> Self
pub fn set_proc_dir_paths<ProcDirPaths>( self, proc_dir_paths: ProcDirPaths, ) -> Self
Sets the function to process the paths and subpaths contained in a directory.
Sourcepub fn set_proc_path<ProcPath>(self, proc_path: ProcPath) -> Self
pub fn set_proc_path<ProcPath>(self, proc_path: ProcPath) -> Self
Sets the function to process a single path.
Sourcepub fn run(
self,
config: Config,
files_data: FilesData,
) -> Result<HashMap<String, Vec<PathBuf>>, ConcurrentErrors>
pub fn run( self, config: Config, files_data: FilesData, ) -> Result<HashMap<String, Vec<PathBuf>>, ConcurrentErrors>
Runs the producer-consumer approach to process the files contained in a directory and in its own subdirectories.
config- Information used to process a file.files_data- Information about the files to be included or excluded from a search more the number of paths considered in the search.
§Errors
Returns ConcurrentErrors::Thread when any worker thread
(the single producer OR one of the num_jobs consumers)
cannot be spawned via std::thread::Builder::spawn;
ConcurrentErrors::Producer when the producer thread
panics during its directory walk and join fails;
ConcurrentErrors::Sender when a worker cannot place an
item (or the post-walk None poison-pill) on the channel;
ConcurrentErrors::Receiver when a consumer thread panics
and its join fails. Per-file processing errors raised by the
user-supplied callbacks are surfaced through the callbacks
themselves, not through this Result.