datex_core/runtime/execution/execution_loop/
interrupts.rs1use core::cell::RefCell;
2
3use crate::{
4 global::protocol_structures::instructions::{
5 RawInternalPointerAddress, RawLocalPointerAddress,
6 RawRemotePointerAddress,
7 },
8 values::value_container::ValueContainer,
9};
10
11use crate::{prelude::*, shared_values::pointer::PointerReferenceMutability};
12
13#[derive(Debug)]
14pub enum ExecutionInterrupt {
15 SetActiveValue(Option<ValueContainer>),
17 External(ExternalExecutionInterrupt),
19}
20
21#[derive(Debug)]
22pub enum ExternalExecutionInterrupt {
23 Result(Option<ValueContainer>),
24 GetReferenceToRemotePointer(
25 RawRemotePointerAddress,
26 PointerReferenceMutability,
27 ),
28 GetReferenceToLocalPointer(RawLocalPointerAddress),
29 GetReferenceInternalPointer(RawInternalPointerAddress),
30 RemoteExecution(ValueContainer, Vec<u8>),
31 Apply(ValueContainer, Vec<ValueContainer>),
32}
33
34#[derive(Debug)]
35pub enum InterruptResult {
36 ResolvedValue(Option<ValueContainer>),
37}
38
39#[derive(Debug, Clone)]
40pub struct InterruptProvider {
41 result: Rc<RefCell<Option<InterruptResult>>>,
42}
43
44impl Default for InterruptProvider {
45 fn default() -> Self {
46 Self::new()
47 }
48}
49
50impl InterruptProvider {
51 pub fn new() -> Self {
52 Self {
53 result: Rc::new(RefCell::new(None)),
54 }
55 }
56
57 pub fn provide_result(&self, result: InterruptResult) {
58 *self.result.borrow_mut() = Some(result);
59 }
60
61 pub fn take_result(&self) -> Option<InterruptResult> {
62 self.result.borrow_mut().take()
63 }
64}