use super::handler::{EngineContext, EventHandler};
use super::pump::EventPump;
use bpm_engine_core::EngineEvent;
use bpm_engine_storage::TokenStore;
use std::sync::Arc;
pub struct Engine<S> {
store: Arc<S>,
}
impl<S> Engine<S>
where
S: TokenStore + Send + Sync + 'static,
{
pub fn new(store: Arc<S>) -> Self {
Self { store }
}
pub async fn tick(&self) -> anyhow::Result<()> {
let _ = &self.store;
Ok(())
}
}
pub struct BpmEngine {
pub handlers: Vec<Box<dyn EventHandler>>,
}
impl BpmEngine {
pub fn new(handlers: Vec<Box<dyn EventHandler>>) -> Self {
BpmEngine { handlers }
}
pub async fn run_async(&self, initial: EngineEvent, ctx: &mut EngineContext) {
EventPump::run_async(&self.handlers, initial, ctx).await;
}
}