~starkingdoms/starkingdoms

ref: 6d234cf18d7b6def2bffd0418685f3de50cdf677 starkingdoms/server/src/timer.rs -rw-r--r-- 563 bytes
6d234cf1 — ghostlyzsh haha oops apparently didnt add files (silly me) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::time::Duration;
use log::{error};

use tokio::time::sleep;
use crate::handler::{ClientHandlerMessage, ClientManager};

pub async fn timer_main(mgr: ClientManager) {
    loop {
        sleep(Duration::from_millis(5)).await;



        for (_addr, client_thread) in mgr.handlers.read().await.iter() {
            match client_thread.tx.send(ClientHandlerMessage::Tick).await {
                Ok(_) => (),
                Err(e) => {
                    error!("unable to update a client thread: {}", e);
                }
            }
        }
    }
}