use observe::Observation;
use super::TaskOutcome;
pub(crate) struct Completion<T> {
task: tokio::task::JoinHandle<()>,
outcome: Observation<TaskOutcome<T>>,
}
impl<T> Completion<T> {
pub(crate) const fn new(
task: tokio::task::JoinHandle<()>,
outcome: Observation<TaskOutcome<T>>,
) -> Self {
Self { task, outcome }
}
pub(crate) async fn wait(self) -> TaskOutcome<T> {
let _task_result = self.task.await;
self.outcome
.into_outcome()
.expect("terminal actor task must publish one outcome before completion")
}
}