File size: 947 Bytes
afa0cbf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | use std::sync::Arc;
use tokio_util::sync::CancellationToken;
use super::notify_cell_closed;
use super::session_registry::CellOwner;
struct CleanupInner {
complete: CancellationToken,
}
#[derive(Clone)]
pub(in crate::remote_session) struct SessionCleanup {
inner: Arc<CleanupInner>,
}
impl SessionCleanup {
pub(in crate::remote_session) fn new() -> Self {
Self {
inner: Arc::new(CleanupInner {
complete: CancellationToken::new(),
}),
}
}
pub(super) fn fail(&self, cells: Vec<CellOwner>) {
for owner in cells {
notify_cell_closed(&owner.delegate, &owner.cell_id);
}
self.inner.complete.cancel();
}
pub(in crate::remote_session) async fn wait(&self) {
self.inner.complete.cancelled().await;
}
pub(in crate::remote_session) fn is_complete(&self) -> bool {
self.inner.complete.is_cancelled()
}
}
|