Repository: tokio-rs/tokio
File: tokio/src/runtime/mod.rs (Rust)

Code before:
    /// [mod]: index.html
    /// [`new`]: method@Self::new
    /// [`Builder`]: struct@Builder
    #[derive(Debug)]
    pub struct Runtime {
        /// Task scheduler
        scheduler: Scheduler,

        /// Handle to runtime, also contains driver handles
        handle: Handle,

        /// Blocking pool handle, used to signal shutdown
        blocking_pool: BlockingPool,
    }

    /// The flavor of a `Runtime`.
    ///
    /// This is the return type for [`Handle::runtime_flavor`](crate::runtime::Handle::runtime_flavor()).
    #[derive(Debug, PartialEq, Eq)]
    #[non_exhaustive]
    pub enum RuntimeFlavor {
        /// The flavor that executes all tasks on the current thread.
        CurrentThread,
        /// The flavor that executes tasks across multiple threads.
        #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
        MultiThread,
    }

    /// The runtime scheduler is either a multi-thread or a current-thread executor.
    #[derive(Debug)]
    enum Scheduler {
        /// Execute all tasks on the current-thread.
        CurrentThread(CurrentThread),

        /// Execute tasks across multiple threads.
        #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
        MultiThread(MultiThread),
    }

    /// After thread starts / before thread stops
    type Callback = std::sync::Arc<dyn Fn() + Send + Sync>;

    impl Runtime {
        cfg_not_wasi! {
            /// Creates a new runtime instance with default configuration values.
            ///
            /// This results in the multi threaded scheduler, I/O driver, and time driver being
            /// initialized.
            ///
            /// Most applications will not need to call this function directly. Instead,
            /// they will use the  [`#[tokio::main]` attribute][main]. When a more complex

Review comment (suggestion):
Actually, I think it should exist in this enum even if the feature is disabled. Otherwise downstream crates will need their own cfg to compile out the branch.

Code after:
    /// [mod]: index.html
    /// [`new`]: method@Self::new
    /// [`Builder`]: struct@Builder
    #[derive(Debug)]
    pub struct Runtime {
        /// Task scheduler
        scheduler: Scheduler,

        /// Handle to runtime, also contains driver handles
        handle: Handle,

        /// Blocking pool handle, used to signal shutdown
        blocking_pool: BlockingPool,
    }

    /// The flavor of a `Runtime`.
    ///
    /// This is the return type for [`Handle::runtime_flavor`](crate::runtime::Handle::runtime_flavor()).
    #[derive(Debug, PartialEq, Eq)]
    #[non_exhaustive]
    pub enum RuntimeFlavor {
        /// The flavor that executes all tasks on the current thread.
        CurrentThread,
        /// The flavor that executes tasks across multiple threads.
        MultiThread,
    }

    /// The runtime scheduler is either a multi-thread or a current-thread executor.
    #[derive(Debug)]
    enum Scheduler {
        /// Execute all tasks on the current-thread.
        CurrentThread(CurrentThread),

        /// Execute tasks across multiple threads.
        #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
        MultiThread(MultiThread),
    }

    /// After thread starts / before thread stops
    type Callback = std::sync::Arc<dyn Fn() + Send + Sync>;

    impl Runtime {
        cfg_not_wasi! {
            /// Creates a new runtime instance with default configuration values.
            ///
            /// This results in the multi threaded scheduler, I/O driver, and time driver being
            /// initialized.
            ///
            /// Most applications will not need to call this function directly. Instead,
            /// they will use the  [`#[tokio::main]` attribute][main]. When a more complex
            /// configuration is necessary, the [runtime builder] may be used.