Skip to main content

qubit_executor/service/
shutdown_report.rs

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