use crate::executor::MVHashMapView;
use std::{fmt::Debug, hash::Hash};
#[derive(Debug)]
pub enum ExecutionStatus<T, E> {
Success(T),
Abort(E),
SkipRest(T),
}
pub trait Transaction: Sync + Send + 'static {
type Key: PartialOrd + Send + Sync + Clone + Hash + Eq;
type Value: Send + Sync;
}
pub struct Accesses<K> {
pub keys_read: Vec<K>,
pub keys_written: Vec<K>,
}
pub trait ExecutorTask: Sync {
type T: Transaction;
type Output: TransactionOutput<T = Self::T> + 'static;
type Error: Clone + Send + Sync + 'static;
type Argument: Sync + Copy;
fn init(args: Self::Argument) -> Self;
fn execute_transaction(
&self,
view: &MVHashMapView<<Self::T as Transaction>::Key, <Self::T as Transaction>::Value>,
txn: &Self::T,
) -> ExecutionStatus<Self::Output, Self::Error>;
}
pub trait TransactionOutput: Send + Sync {
type T: Transaction;
fn get_writes(
&self,
) -> Vec<(
<Self::T as Transaction>::Key,
<Self::T as Transaction>::Value,
)>;
fn skip_output() -> Self;
}