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

Code before:
    /// Specifies the random number generation seed to use within all threads associated
    /// with the runtime being built.
    ///
    /// This option is intended to make certain parts of the runtime deterministic.
    /// Specifically, it affects the [`tokio::select!`] macro and the work stealing
    /// algorithm. In the case of [`tokio::select!`] it will ensure that the order that
    /// branches are polled is deterministic.
    ///
    /// In the case of work stealing, it's a little more complicated. Each worker will
    /// be given a deterministic seed so that the starting peer for each work stealing
    /// search will be deterministic.
    ///
    /// # Examples
    ///
    /// ```
    /// # use tokio::runtime::{self, RngSeed};
    /// # pub fn main() {
    /// let seed = RngSeed::from_bytes(b"place your seed here");
    /// let rt = runtime::Builder::new_current_thread()
    ///     .rng_seed(seed)
    ///     .build();
    /// # }
    /// ```
    ///
    /// [`tokio::select!`]: crate::select
    pub fn rng_seed(&mut self, seed: RngSeed) -> &mut Self {
        self.seed_generator = RngSeedGenerator::new(seed);
        self
    }

    cfg_unstable! {
        /// Configure how the runtime responds to an unhandled panic on a
        /// spawned task.
        ///
        /// By default, an unhandled panic (i.e. a panic not caught by
        /// [`std::panic::catch_unwind`]) has no impact on the runtime's
        /// execution. The panic is error value is forwarded to the task's
        /// [`JoinHandle`] and all other spawned tasks continue running.
        ///
        /// The `unhandled_panic` option enables configuring this behavior.
        ///
        /// * `UnhandledPanic::Ignore` is the default behavior. Panics on
        ///   spawned tasks have no impact on the runtime's execution.
        /// * `UnhandledPanic::ShutdownRuntime` will force the runtime to
        ///   shutdown immediately when a spawned task panics even if that
        ///   task's `JoinHandle` has not been dropped. All other spawned tasks
        ///   will immediately terminate and further calls to
        ///   [`Runtime::block_on`] will panic.
        ///
        /// # Unstable
        ///

Review comment (suggestion):
Lets start by including this as unstable and let consumers (e.g. [`Turmoil`](github.com/tokio-rs/turmoil) validate it first).

Code after:
        /// spawned task.
        ///
        /// By default, an unhandled panic (i.e. a panic not caught by
        /// [`std::panic::catch_unwind`]) has no impact on the runtime's
        /// execution. The panic is error value is forwarded to the task's
        /// [`JoinHandle`] and all other spawned tasks continue running.
        ///
        /// The `unhandled_panic` option enables configuring this behavior.
        ///
        /// * `UnhandledPanic::Ignore` is the default behavior. Panics on
        ///   spawned tasks have no impact on the runtime's execution.
        /// * `UnhandledPanic::ShutdownRuntime` will force the runtime to
        ///   shutdown immediately when a spawned task panics even if that
        ///   task's `JoinHandle` has not been dropped. All other spawned tasks
        ///   will immediately terminate and further calls to
        ///   [`Runtime::block_on`] will panic.
        ///
        /// # Unstable
        ///
        /// This option is currently unstable and its implementation is
        /// incomplete. The API may change or be removed in the future. See
        /// tokio-rs/tokio#4516 for more details.
        ///
        /// # Examples
        ///
        /// The following demonstrates a runtime configured to shutdown on
        /// panic. The first spawned task panics and results in the runtime
        /// shutting down. The second spawned task never has a chance to
        /// execute. The call to `block_on` will panic due to the runtime being
        /// forcibly shutdown.
        ///
        /// ```should_panic
        /// use tokio::runtime::{self, UnhandledPanic};
        ///
        /// # pub fn main() {
        /// let rt = runtime::Builder::new_current_thread()
        ///     .unhandled_panic(UnhandledPanic::ShutdownRuntime)
        ///     .build()
        ///     .unwrap();
        ///
        /// rt.spawn(async { panic!("boom"); });
        /// rt.spawn(async {
        ///     // This task never completes.
        /// });
        ///
        /// rt.block_on(async {
        ///     // Do some work
        /// # loop { tokio::task::yield_now().await; }
        /// })
        /// # }
        /// ```