add scheduler
This commit is contained in:
parent
64ca05738c
commit
543c57516f
2 changed files with 38 additions and 1 deletions
35
src/main.rs
35
src/main.rs
|
@ -1,3 +1,36 @@
|
|||
use std::{
|
||||
thread,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
pub mod revanced;
|
||||
|
||||
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
4
src/revanced.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
pub fn debug() {
|
||||
eprintln!("Hello, world!");
|
||||
std::thread::sleep(std::time::Duration::from_millis(100))
|
||||
}
|
Loading…
Reference in a new issue