Skip to main content

qubit_execution_services/
execution_services_stop_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//! Stop report for the execution-services facade.
11
12use super::StopReport;
13
14/// Aggregate report returned by [`super::ExecutionServices::stop`].
15#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
16pub struct ExecutionServicesStopReport {
17    /// Stop report for the blocking executor domain.
18    pub blocking: StopReport,
19    /// Stop report for the CPU executor domain.
20    pub cpu: StopReport,
21    /// Stop report for the Tokio blocking executor domain.
22    pub tokio_blocking: StopReport,
23    /// Stop report for the Tokio async IO executor domain.
24    pub io: StopReport,
25}
26
27impl ExecutionServicesStopReport {
28    /// Returns the total queued task count across all execution domains.
29    ///
30    /// # Returns
31    ///
32    /// The sum of every domain's queued-task count.
33    #[inline]
34    pub const fn total_queued(&self) -> usize {
35        self.blocking.queued + self.cpu.queued + self.tokio_blocking.queued + self.io.queued
36    }
37
38    /// Returns the total running task count across all execution domains.
39    ///
40    /// # Returns
41    ///
42    /// The sum of every domain's running-task count.
43    #[inline]
44    pub const fn total_running(&self) -> usize {
45        self.blocking.running + self.cpu.running + self.tokio_blocking.running + self.io.running
46    }
47
48    /// Returns the total cancellation count across all execution domains.
49    ///
50    /// # Returns
51    ///
52    /// The sum of every domain's cancelled-task count.
53    #[inline]
54    pub const fn total_cancelled(&self) -> usize {
55        self.blocking.cancelled
56            + self.cpu.cancelled
57            + self.tokio_blocking.cancelled
58            + self.io.cancelled
59    }
60}