busy wait for macos
This commit is contained in:
@@ -17,7 +17,6 @@ use std::thread::scope;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use pixels::{Error, Pixels, SurfaceTexture};
|
||||
use wait_on_address::AtomicWait;
|
||||
use winit::application::ApplicationHandler;
|
||||
use winit::dpi::LogicalSize;
|
||||
use winit::event::WindowEvent;
|
||||
@@ -27,6 +26,8 @@ use winit::window::Window;
|
||||
// use winit_input_helper::WinitInputHelper;
|
||||
|
||||
use crate::cpu::{Computer, MMIOInterupt};
|
||||
mod wait;
|
||||
use wait::WaitOnAtomic;
|
||||
mod cpu;
|
||||
use cpu::SHARED;
|
||||
|
||||
@@ -121,7 +122,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
(&SHARED.external_interupts).store(MMIOInterupt::Keyboard.into(), Release);
|
||||
#[cfg(feature = "debug")]
|
||||
println!("wake due to keyboard event");
|
||||
SHARED.external_interupts.notify_one();
|
||||
SHARED.external_interupts.signal();
|
||||
}
|
||||
}
|
||||
WindowEvent::CursorMoved { position, .. } => {
|
||||
@@ -150,7 +151,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
(&SHARED.external_interupts).store(MMIOInterupt::MouseMove.into(), Release);
|
||||
#[cfg(feature = "debug")]
|
||||
println!("wake due mouse move");
|
||||
SHARED.external_interupts.notify_one();
|
||||
SHARED.external_interupts.signal();
|
||||
}
|
||||
}
|
||||
// WindowEvent::MouseWheel {
|
||||
@@ -184,7 +185,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
(&SHARED.external_interupts).store(MMIOInterupt::MouseClick.into(), Release);
|
||||
#[cfg(feature = "debug")]
|
||||
println!("wake mouse click");
|
||||
SHARED.external_interupts.notify_one();
|
||||
SHARED.external_interupts.signal();
|
||||
}
|
||||
}
|
||||
WindowEvent::ScaleFactorChanged { .. } => {
|
||||
@@ -197,7 +198,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
!= 0;
|
||||
if enabled {
|
||||
(&SHARED.external_interupts).store(MMIOInterupt::VSync.into(), Relaxed);
|
||||
SHARED.external_interupts.notify_one();
|
||||
SHARED.external_interupts.signal();
|
||||
wait_int();
|
||||
}
|
||||
let pix = self.pixels.as_mut().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user