use std::time::Duration;
use crate::event_node::EventNode;
pub trait Reactor {
fn wait(&self) -> EventId;
}
pub trait TemporalReactor: Reactor {
const MAX_TIMER_DURATION_MS: u32 = 24 * 60 * 60 * 1000;
fn schedule_timer(&self, event_id: EventId, duration: Duration);
fn cancel_timer(&self, event_id: EventId);
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct EventId(pub(crate) *const ());
impl EventId {
pub fn null() -> Self {
EventId(std::ptr::null())
}
pub fn as_event_node(&self) -> &EventNode {
assert!(self.0 != std::ptr::null());
unsafe { &*(self.0 as *const EventNode) }
}
}