Skip to content

Instantly share code, notes, and snippets.

@z3t0
Created August 2, 2016 06:02
Show Gist options
  • Select an option

  • Save z3t0/61d615fcb47c9cf547e91fc54b4019bc to your computer and use it in GitHub Desktop.

Select an option

Save z3t0/61d615fcb47c9cf547e91fc54b4019bc to your computer and use it in GitHub Desktop.
// Nolag Server : Main
// Rafi Khan
extern crate time;
use std::thread::sleep;
use std::time::Duration;
// runs loop update_rate times a second
fn main() {
let now = time::precise_time_s();
let update_rate = 50000000; // every 50ms
loop {
let start = time::precise_time_ns();
println!("Time : {}", time::precise_time_s() - now);
sleep(Duration::new(0, (start + update_rate - time::precise_time_ns()) as u32));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment