use std::sync::Arc;
use crate::tokio_executor_service_state::TokioExecutorServiceState;
pub(crate) struct TokioServiceTaskGuard {
state: Arc<TokioExecutorServiceState>,
marker: Arc<()>,
}
impl TokioServiceTaskGuard {
pub(crate) fn new(state: Arc<TokioExecutorServiceState>, marker: Arc<()>) -> Self {
Self { state, marker }
}
}
impl Drop for TokioServiceTaskGuard {
fn drop(&mut self) {
self.state.remove_abort_handle(&self.marker);
if self.state.active_tasks.dec() == 0 {
self.state.notify_if_terminated();
}
}
}