mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-10-25 21:40:09 +00:00
interval introduced to avoid massive cpu usage
This commit is contained in:
1 parent
c5ce152a30
commit
5d8c9cd792
1 file changed
+6
@@ -39,9 +39,15 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| error!("{:?}", e))
|
.map_err(|e| error!("{:?}", e))
|
||||||
.expect("Failed to start server!");
|
.expect("Failed to start server!");
|
||||||
|
|
||||||
|
// TODO: It'd be nicer if we didn't have to rely on this interval to limit the amount of times
|
||||||
|
// the loop can run per second. It'd be much better if it idled until one of the connections
|
||||||
|
// had a packet ready.
|
||||||
|
let mut interval = tokio::time::interval(tokio::time::Duration::from_nanos(1000)); // 5 ms = max 200 ticks per second
|
||||||
loop {
|
loop {
|
||||||
if let Err(e) = server.process().await {
|
if let Err(e) = server.process().await {
|
||||||
error!("{:?}", e);
|
error!("{:?}", e);
|
||||||
}
|
}
|
||||||
|
interval.tick().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user