mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-13 14:24:46 +10:00
Progress checker works
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
use crate::utils::ProgressChecker::Complete;
|
||||
use rayon::{ThreadPool, ThreadPoolBuilder};
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
pub enum ProgressChecker {
|
||||
Complete,
|
||||
Incomplete
|
||||
}
|
||||
|
||||
/*
|
||||
// This function is designed to take in any function which does not regularly return a value,
|
||||
// and instead loops over it until it returns "Complete". The current number of iterations
|
||||
// is counted by "progress"
|
||||
@@ -18,16 +14,20 @@ pub async fn progress_updater(function: Box<dyn Fn() -> ProgressChecker>, progre
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn new_progress_updater<T, D>(function: Box<dyn Fn(T) -> D>, contexts: T, progress: AtomicUsize) {
|
||||
|
||||
}
|
||||
|
||||
pub async fn threaded_progress_updater<F>(f: F, progress: AtomicUsize, max_threads: usize, instances: usize) -> ProgressChecker
|
||||
where F: Fn() -> ProgressChecker + Send + Clone + Copy + 'static
|
||||
{
|
||||
let mut threads = Vec::new();
|
||||
let pool = ThreadPoolBuilder::new().num_threads(max_threads).build().unwrap();
|
||||
for instance in 0..instances {
|
||||
let func = tokio::spawn(async move {
|
||||
pool.spawn(move || -> ProgressChecker {
|
||||
let res = f();
|
||||
return res
|
||||
});
|
||||
threads.push(func);
|
||||
}
|
||||
let mut completed = ProgressChecker::Incomplete;
|
||||
for thread in threads {
|
||||
@@ -41,4 +41,5 @@ where F: Fn() -> ProgressChecker + Send + Clone + Copy + 'static
|
||||
|
||||
fn test() -> ProgressChecker {
|
||||
ProgressChecker::Incomplete
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user