forked from MightyPork/crsn
use 'spin_sleep' for more accurate execution rate, add "s", "m", "u" suffix support to the -C argument
This commit is contained in:
@@ -14,3 +14,4 @@ log = "0.4.11"
|
||||
num-traits = "0.2.12"
|
||||
parking_lot = "0.11.0"
|
||||
nudge = "0.2.1"
|
||||
spin_sleep = "1.0.0"
|
||||
|
||||
@@ -11,4 +11,3 @@ description = "A small, simple, self-contained, s-expression parser and pretty-p
|
||||
license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.11"
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use std::str::{self, FromStr};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use std::thread::JoinHandle;
|
||||
use std::time::Duration;
|
||||
use std::time::{Duration};
|
||||
|
||||
pub use info::ThreadInfo;
|
||||
pub use state::RunState;
|
||||
@@ -66,11 +66,16 @@ impl RunThread {
|
||||
|
||||
/// Start synchronously
|
||||
pub fn run(mut self) {
|
||||
let mut loop_helper = spin_sleep::LoopHelper::builder()
|
||||
.build_with_target_rate(1.0/self.info.cycle_time.as_secs_f64());
|
||||
|
||||
loop_helper.loop_start();
|
||||
'run: loop {
|
||||
match self.eval_op() {
|
||||
Ok(EvalRes { cycles, advance }) => {
|
||||
if cycles > 0 {
|
||||
std::thread::sleep(self.info.cycle_time * (cycles as u32));
|
||||
for _ in 0..cycles {
|
||||
loop_helper.loop_sleep();
|
||||
loop_helper.loop_start();
|
||||
}
|
||||
trace!("Step {}; Status = {}", advance, self.state.frame.status);
|
||||
self.state.frame.pc.advance(advance);
|
||||
|
||||
Reference in New Issue
Block a user