add scheduler

This commit is contained in:
Mylloon 2023-09-03 12:04:45 +02:00
parent 64ca05738c
commit 543c57516f
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 38 additions and 1 deletions

View file

@ -1,3 +1,36 @@
use std::{
thread,
time::{Duration, Instant},
};
pub mod revanced;
fn main() { fn main() {
println!("Hello, world!"); let scheduler = thread::spawn(|| {
let wait_time = Duration::from_secs(60 * 60 * 12);
loop {
let start = Instant::now();
eprintln!("Scheduler starting");
// Prepare threads
let thread_a = thread::spawn(revanced::debug);
// Run threads
thread_a.join().expect("Thread A panicked");
let runtime = start.elapsed();
if let Some(remaining) = wait_time.checked_sub(runtime) {
eprintln!(
"Waiting for {} seconds before next run",
remaining.as_secs()
);
thread::sleep(remaining);
}
}
});
// Run scheduler
scheduler.join().expect("Scheduler panicked");
} }

4
src/revanced.rs Normal file
View file

@ -0,0 +1,4 @@
pub fn debug() {
eprintln!("Hello, world!");
std::thread::sleep(std::time::Duration::from_millis(100))
}