Use high-priority thread for emulation
This commit is contained in:
+16
-11
@@ -1,9 +1,10 @@
|
||||
use std::{path::PathBuf, process, thread};
|
||||
use std::{path::PathBuf, process};
|
||||
|
||||
use anyhow::Result;
|
||||
use app::App;
|
||||
use clap::Parser;
|
||||
use emulator::EmulatorBuilder;
|
||||
use thread_priority::{ThreadBuilder, ThreadPriority};
|
||||
use winit::event_loop::{ControlFlow, EventLoop};
|
||||
|
||||
mod app;
|
||||
@@ -26,16 +27,20 @@ fn main() -> Result<()> {
|
||||
if let Some(path) = args.rom {
|
||||
builder = builder.with_rom(&path);
|
||||
}
|
||||
thread::spawn(move || {
|
||||
let mut emulator = match builder.build() {
|
||||
Ok(e) => e,
|
||||
Err(err) => {
|
||||
eprintln!("Error initializing emulator: {err}");
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
emulator.run();
|
||||
});
|
||||
|
||||
ThreadBuilder::default()
|
||||
.name("Emulator".to_owned())
|
||||
.priority(ThreadPriority::Max)
|
||||
.spawn_careless(move || {
|
||||
let mut emulator = match builder.build() {
|
||||
Ok(e) => e,
|
||||
Err(err) => {
|
||||
eprintln!("Error initializing emulator: {err}");
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
emulator.run();
|
||||
})?;
|
||||
|
||||
let event_loop = EventLoop::with_user_event().build().unwrap();
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
|
||||
Reference in New Issue
Block a user