Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
30
third-party/vendor/calloop/examples/high_precision.rs
vendored
Normal file
30
third-party/vendor/calloop/examples/high_precision.rs
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use std::time::{Duration, Instant};
|
||||
|
||||
use calloop::{
|
||||
timer::{TimeoutAction, Timer},
|
||||
EventLoop,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let mut event_loop =
|
||||
EventLoop::try_new_high_precision().expect("Failed to initialize the event loop!");
|
||||
|
||||
let before = Instant::now();
|
||||
|
||||
event_loop
|
||||
.handle()
|
||||
.insert_source(
|
||||
Timer::from_duration(Duration::from_micros(20)),
|
||||
|_, _, _| TimeoutAction::Drop,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
event_loop.dispatch(None, &mut ()).unwrap();
|
||||
|
||||
let elapsed = before.elapsed();
|
||||
|
||||
println!(
|
||||
"The event loop slept for {} microseconds.",
|
||||
elapsed.as_micros()
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue