Reduce load by not constantly spawning new threads for sleeping
This commit is contained in:
parent
817f777059
commit
ebbaed0973
1 changed files with 1 additions and 8 deletions
|
@ -86,9 +86,6 @@ async fn postgres_watchdog(pool: PgPool, is_alive: Arc<AtomicBool>, shutdown: Ar
|
||||||
println!("No Uptime Kuma URL provided!");
|
println!("No Uptime Kuma URL provided!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let passed = (Local::now() - start).to_std().expect(&format!("Unable to get Time Difference for '{}' and '{}'", start, Local::now()));
|
|
||||||
|
|
||||||
while Local::now() - start < chrono::Duration::seconds(15) {
|
while Local::now() - start < chrono::Duration::seconds(15) {
|
||||||
sleep(Duration::from_millis(100)).await;
|
sleep(Duration::from_millis(100)).await;
|
||||||
if shutdown.load(Ordering::Relaxed) {
|
if shutdown.load(Ordering::Relaxed) {
|
||||||
|
@ -296,11 +293,7 @@ async fn main() -> Result<()> {
|
||||||
//watchdog_thread.await;
|
//watchdog_thread.await;
|
||||||
|
|
||||||
while is_alive.load(Ordering::Relaxed) {
|
while is_alive.load(Ordering::Relaxed) {
|
||||||
let thread = tokio::spawn(async {
|
sleep(Duration::from_millis(200)).await;
|
||||||
let _ = sleep(Duration::from_millis(100));
|
|
||||||
});
|
|
||||||
|
|
||||||
let _ = thread.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if shutdown.load(Ordering::Relaxed) {
|
if shutdown.load(Ordering::Relaxed) {
|
||||||
|
|
Reference in a new issue