use std::pin::Pin;

use futures::Future;
use tokio::{task::JoinError, time::error::Elapsed};

use crate::{DefaultCommitPolicy, ShardError, ShardShutdownStats};

use super::{commit_policy::InnerCommitPolicy, InternalJoinSetResult};

pub(super) type ExecuteFn<Data> = Box<dyn FnOnce(Result<&Data, ShardError>) + Send>;

pub(super) type ExecuteMutFn<Data> =
    Box<dyn FnOnce(Result<&mut Data, ShardError>, DefaultCommitPolicy) -> InnerCommitPolicy + Send>;

pub(super) type ExecuteIfCachedFn<Data> = Box<dyn FnOnce(Option<&Data>) + Send>;

pub(super) type GracefulShutdownFuture =
    Pin<Box<dyn Future<Output = Result<Vec<ShardShutdownStats>, ShardError>> + Send + 'static>>;
