use crate::id::types::{ChildId, SupervisorPath};
use crate::task::context::TaskContext;
#[derive(Debug, Clone)]
pub struct WorkerContext {
inner: TaskContext,
}
impl WorkerContext {
pub fn new(inner: TaskContext) -> Self {
Self { inner }
}
pub fn ready(&self) {
self.inner.mark_ready();
}
pub fn heartbeat(&self) {
self.inner.heartbeat();
}
pub fn is_cancelled(&self) -> bool {
self.inner.is_cancelled()
}
pub async fn wait_cancelled(&self) {
self.inner.cancellation_token().cancelled().await;
}
pub fn child_id(&self) -> &ChildId {
&self.inner.child_id
}
pub fn path(&self) -> &SupervisorPath {
&self.inner.path
}
}