cpu/
context.rs

1//! This module manages the context in which the emulator is performing a single operation.
2//!
3//! In general, a function call into the emulator represents an
4//! opportunity to execute an instruction or to emulatge a state
5//! change for a peripheral.
6//!
7//! The emulator is most concerned with keeping track of hoe much time
8//! would have elapsed for the TX-2 machine it is emulating.  This
9//! allows is to know, for example, when the Lincoln Writer would have
10//! finished printing a character, when the next value from the paper
11//! tape reader would be ready and so on.  But the caller also keeps
12//! track of the actual elapsed time.
13//!
14//! In order to avoid confusion between these related quantities of
15//! the same type, we keep them together in a struct so that we can
16//! give them very clear names.
17use core::time::Duration;
18
19/// State shared between the emulator and the UI.
20#[derive(Debug)]
21pub struct Context {
22    pub simulated_time: Duration,
23    pub real_elapsed_time: Duration,
24}
25
26impl Context {
27    #[must_use]
28    pub fn new(simulated_time: Duration, real_elapsed_time: Duration) -> Context {
29        Context {
30            simulated_time,
31            real_elapsed_time,
32        }
33    }
34}