~starkingdoms/starkingdoms

ref: 8040f221e2a80d88a7a5ba849aa4eb8912388f71 starkingdoms/server/src/timer.rs -rw-r--r-- 563 bytes
8040f221 — ghostlyzsh yay merged the file swap (why git why) 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::manager::{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);
                }
            }
        }
    }
}