busy wait for macos
This commit is contained in:
@@ -8,11 +8,13 @@ pixels = "0.15.0"
|
||||
winit = { version = "0.30.13", features = ["x11", "x11-dl", "x11rb", "ahash", "bytemuck", "memmap2", "rwh_06", "sctk", "sctk-adwaita"] }
|
||||
winit_input_helper = "0.17.0"
|
||||
parse_int = { version = "0.9.0", optional = true }
|
||||
wait_on_address = "0.1.4"
|
||||
wait_on_address = { version = "0.1.4", optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
default = ["futex"]
|
||||
div_mul = []
|
||||
rgba = []
|
||||
rich_keyboard = []
|
||||
debug = ["dep:parse_int"]
|
||||
futex = ["dep:wait_on_address"]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::wait::WaitOnAtomic;
|
||||
#[cfg(feature = "debug")]
|
||||
use std::collections::HashMap;
|
||||
use std::{
|
||||
@@ -9,7 +10,6 @@ use std::{
|
||||
sync::atomic::AtomicU32,
|
||||
time::{self, Instant},
|
||||
};
|
||||
use wait_on_address::AtomicWait;
|
||||
pub(crate) struct SharedState {
|
||||
pub(crate) keyboard: [AtomicU32; 4],
|
||||
pub(crate) screen_buf: [AtomicU32; 480 * 640],
|
||||
@@ -643,7 +643,7 @@ impl Computer {
|
||||
InteruptKind::MMIO => {
|
||||
(&SHARED.external_interupts)
|
||||
.store(0, std::sync::atomic::Ordering::Release);
|
||||
SHARED.external_interupts.notify_one();
|
||||
SHARED.external_interupts.signal();
|
||||
//no need to check prev because MMIO is the lowest priority
|
||||
self.interupts = InteruptState::Enabled
|
||||
}
|
||||
@@ -688,7 +688,7 @@ impl Computer {
|
||||
(&SHARED.external_enabled_interupts)
|
||||
.store(0, std::sync::atomic::Ordering::Relaxed);
|
||||
(&SHARED.external_interupts).store(0, std::sync::atomic::Ordering::Relaxed);
|
||||
SHARED.external_interupts.notify_all();
|
||||
SHARED.external_interupts.signal();
|
||||
}
|
||||
Instruction::Swi() => {
|
||||
self.pc += 1;
|
||||
|
||||
@@ -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