use std::collections::{HashMap, VecDeque};
use crate::engine::call_context::CallContext;
use crate::engine::pending_async::{ExecutionState, PendingAsync};
use crate::ids::{CommandId, ExecId, NodeSiteId, OpRef};
use crate::runtime::PendingCompletion;
use crate::slot_value::SlotValue;
#[derive(Default)]
pub struct IdAllocator {
pub next_exec_id: u64,
pub next_command_id: u64,
pub next_node_site_id: u64,
}
pub struct ExecState {
pub frontier: VecDeque<(OpRef, ExecId)>,
pub slot_table: HashMap<(NodeSiteId, ExecId), Option<Box<dyn SlotValue>>>,
pub execution_state: HashMap<ExecId, ExecutionState>,
pub pending_async: HashMap<CommandId, PendingAsync>,
pub pending_completions: Vec<PendingCompletion>,
pub pending_calls: HashMap<ExecId, CallContext>,
pub ids: IdAllocator,
}
impl Default for ExecState {
fn default() -> Self {
Self::new()
}
}
impl ExecState {
pub fn new() -> Self {
Self {
frontier: VecDeque::new(),
slot_table: HashMap::new(),
execution_state: HashMap::new(),
pending_async: HashMap::new(),
pending_completions: Vec::new(),
pending_calls: HashMap::new(),
ids: IdAllocator::default(),
}
}
}