Commit 1474ea1c authored by Florian Blasius's avatar Florian Blasius 🤘

Merge branch 'no-async' into 'master'

OrbTk windowing should not be asychronous

See merge request redox-os/orbtk!106
parents 7454d259 faa50843
Pipeline #3715 passed with stages
in 6 minutes and 34 seconds
use std::cell::{Cell, RefCell};
use std::collections::BTreeMap;
use std::rc::Rc;
use std::time;
use orbclient::{self, Color, Mode, Renderer as OrbRenderer, Window as OrbWindow};
......@@ -255,29 +254,17 @@ impl BackendRunner for OrbitalBackendRunner {
self.world = Some(world);
}
fn run(&mut self, update: Rc<Cell<bool>>, running: Rc<Cell<bool>>) {
let target_fps = 60.0;
let target_fps_nanos = (1. / target_fps as f32) * 1_000_000_000.;
let mut last_tick_time = time::Instant::now();
loop {
let sys_time = time::SystemTime::now();
if !running.get() {
break;
}
let time = last_tick_time.elapsed();
let total_nanos = time.as_secs() * 1_000_000_000 + time.subsec_nanos() as u64;
let elapsed = target_fps_nanos - (total_nanos as f32);
if elapsed <= 0. {
if let Some(world) = &mut self.world {
world.run();
}
last_tick_time = time::Instant::now();
update.set(false);
if let Some(world) = &mut self.world {
world.run();
}
update.set(false);
self.backend.borrow_mut().drain_events();
}
}
......
......@@ -22,7 +22,7 @@ pub fn target_backend(
resizable: bool,
theme: Theme,
) -> (Box<OrbitalBackendRunner>, Rc<RefCell<dyn Backend>>) {
let mut flags = vec![WindowFlag::Async];
let mut flags = vec![];
if resizable {
flags.push(WindowFlag::Resizable);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment