Use async in threads with tokio
This commit is contained in:
parent
57d1956c67
commit
53e7a80561
1 changed files with 12 additions and 4 deletions
16
src/main.rs
16
src/main.rs
|
@ -3,21 +3,29 @@ use std::{
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod revanced;
|
mod revanced;
|
||||||
|
|
||||||
fn main() {
|
#[actix_web::main]
|
||||||
|
async fn main() {
|
||||||
let scheduler = thread::spawn(|| {
|
let scheduler = thread::spawn(|| {
|
||||||
let wait_time = Duration::from_secs(60 * 60 * 12);
|
let wait_time = Duration::from_secs(60 * 60 * 12);
|
||||||
|
|
||||||
|
// Tokio runtime
|
||||||
|
let rt = tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_io()
|
||||||
|
.enable_time()
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
eprintln!("Scheduler starting");
|
eprintln!("Scheduler starting");
|
||||||
|
|
||||||
// Prepare threads
|
// Prepare threads
|
||||||
let thread_a = thread::spawn(revanced::debug);
|
let thread_a = thread::spawn(revanced::search);
|
||||||
|
|
||||||
// Run threads
|
// Run threads
|
||||||
thread_a.join().expect("Thread A panicked");
|
rt.block_on(async { thread_a.join().expect("Thread A panicked").await });
|
||||||
|
|
||||||
let runtime = start.elapsed();
|
let runtime = start.elapsed();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue