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