Implemented sleep

This commit is contained in:
Connor Wood
2017-07-22 11:13:30 +01:00
parent ff23827155
commit f8e433c4e7

View File

@@ -292,10 +292,22 @@ fn parse_def_sleep(data: &[u8],
})
}
// TODO: Sleep the processor for the specified number of milliseconds (minimum)
parser_opcode_extended!(data, 0x22);
let time = parse_term_arg(&data[2..], ctx)?;
let timeout = time.val.get_as_integer()?;
let (seconds, nanoseconds) = monotonic();
let starting_time_ns = nanoseconds + (seconds * 1000000000);
loop {
let (seconds, nanoseconds) = monotonic();
let current_time_ns = nanoseconds + (seconds * 1000000000);
if current_time_ns - starting_time_ns > timeout as u64 * 1000000 {
break;
}
}
Ok(AmlParseType {
val: AmlValue::None,