Skip to main content

qubit_executor/service/
shutdown_report.rs

1/*******************************************************************************
2 *
3 *    Copyright (c) 2025 - 2026.
4 *    Haixing Hu, Qubit Co. Ltd.
5 *
6 *    All rights reserved.
7 *
8 ******************************************************************************/
9/// Summary returned by an immediate executor-service shutdown request.
10///
11/// The report is intentionally count-based. In a generic Rust executor service,
12/// pending tasks may have different result and error types, so returning a
13/// strongly typed list of unstarted tasks is not generally meaningful.
14///
15/// # Author
16///
17/// Haixing Hu
18#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
19pub struct ShutdownReport {
20    /// Number of tasks that were still queued when shutdown was requested.
21    pub queued: usize,
22
23    /// Number of tasks that were running when shutdown was requested.
24    pub running: usize,
25
26    /// Number of tasks for which cancellation or abort was requested.
27    pub cancelled: usize,
28}
29
30impl ShutdownReport {
31    /// Creates a new shutdown report from explicit counters.
32    ///
33    /// # Parameters
34    ///
35    /// * `queued` - Number of queued tasks observed during shutdown.
36    /// * `running` - Number of running tasks observed during shutdown.
37    /// * `cancelled` - Number of tasks cancellation was requested for.
38    ///
39    /// # Returns
40    ///
41    /// A report containing the supplied counters.
42    #[inline]
43    pub const fn new(queued: usize, running: usize, cancelled: usize) -> Self {
44        Self {
45            queued,
46            running,
47            cancelled,
48        }
49    }
50}