diff --git a/lib/common/src/instruction.rs b/lib/common/src/instruction.rs index d1d6e36..8643033 100644 --- a/lib/common/src/instruction.rs +++ b/lib/common/src/instruction.rs @@ -33,6 +33,42 @@ impl InstructionFeedback for X X:InstructionEmitter+InstructionConsumer, {} +pub struct InstructionCache{ + instruction_machine:S, + cached_instruction:Option>, + time_limit:Time, +} +impl InstructionCache + where + Time:Copy+Ord, + Option>:Clone, + S:InstructionEmitter+InstructionConsumer +{ + pub fn new( + instruction_machine:S, + )->Self{ + Self{ + instruction_machine, + cached_instruction:None, + time_limit:Time::MIN, + } + } + pub fn next_instruction_cached(&mut self,time_limit:Time)->Option>{ + if time_limit){ + // invalidate cache + self.time_limit=Time::MIN; + self.instruction_machine.process_instruction(instruction); + } +} + //PROPER PRIVATE FIELDS!!! pub struct InstructionCollector{ time:Time,