mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-03 10:00:19 +00:00
refactor(cli): move thread pool setup to command execution, use thread::spawn instead of rayon::spawn in the logger thread
This commit is contained in:
parent
6b38e1dd46
commit
77b01d170f
@ -28,13 +28,6 @@ impl CliArgs {
|
||||
|
||||
set_accessible(args.accessible);
|
||||
|
||||
if let Some(threads) = args.threads {
|
||||
rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(threads)
|
||||
.build_global()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let (Subcommand::Compress { files, .. }
|
||||
| Subcommand::Decompress { files, .. }
|
||||
| Subcommand::List { archives: files, .. }) = &mut args.cmd;
|
||||
|
@ -53,6 +53,14 @@ pub fn run(
|
||||
question_policy: QuestionPolicy,
|
||||
file_visibility_policy: FileVisibilityPolicy,
|
||||
) -> crate::Result<()> {
|
||||
|
||||
if let Some(threads) = args.threads {
|
||||
rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(threads)
|
||||
.build_global()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
match args.cmd {
|
||||
Subcommand::Compress {
|
||||
files,
|
||||
|
@ -1,4 +1,5 @@
|
||||
use std::sync::{mpsc, Arc, Barrier, OnceLock};
|
||||
use std::thread;
|
||||
|
||||
pub use logger_thread::spawn_logger_thread;
|
||||
|
||||
@ -168,7 +169,7 @@ mod logger_thread {
|
||||
|
||||
pub fn spawn_logger_thread() {
|
||||
let log_receiver = setup_channel();
|
||||
rayon::spawn(move || run_logger(log_receiver));
|
||||
thread::spawn(move || run_logger(log_receiver));
|
||||
}
|
||||
|
||||
fn run_logger(log_receiver: LogReceiver) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user