tokio/runtime/
config.rs

1#![cfg_attr(
2    any(not(all(tokio_unstable, feature = "full")), target_family = "wasm"),
3    allow(dead_code)
4)]
5use crate::runtime::{Callback, TaskCallback};
6use crate::util::RngSeedGenerator;
7
8pub(crate) struct Config {
9    /// How many ticks before pulling a task from the global/remote queue?
10    pub(crate) global_queue_interval: Option<u32>,
11
12    /// How many ticks before yielding to the driver for timer and I/O events?
13    pub(crate) event_interval: u32,
14
15    /// Callback for a worker parking itself
16    pub(crate) before_park: Option<Callback>,
17
18    /// Callback for a worker unparking itself
19    pub(crate) after_unpark: Option<Callback>,
20
21    /// To run before each task is spawned.
22    pub(crate) before_spawn: Option<TaskCallback>,
23
24    /// To run after each task is terminated.
25    pub(crate) after_termination: Option<TaskCallback>,
26
27    /// To run before each poll
28    #[cfg(tokio_unstable)]
29    pub(crate) before_poll: Option<TaskCallback>,
30
31    /// To run after each poll
32    #[cfg(tokio_unstable)]
33    pub(crate) after_poll: Option<TaskCallback>,
34
35    /// The multi-threaded scheduler includes a per-worker LIFO slot used to
36    /// store the last scheduled task. This can improve certain usage patterns,
37    /// especially message passing between tasks.
38    ///
39    /// In Tokio versions before 1.51, tasks in the LIFO slot could not be
40    /// stolen, which could cause issues in applications with long poll times.
41    /// As a stop-gap, this unstable option lets users disable the LIFO task.
42    /// Now that the LIFO slot is stealable, we may remove this option in a
43    /// future version.
44    pub(crate) disable_lifo_slot: bool,
45
46    /// Random number generator seed to configure runtimes to act in a
47    /// deterministic way.
48    pub(crate) seed_generator: RngSeedGenerator,
49
50    /// How to build poll time histograms
51    pub(crate) metrics_poll_count_histogram: Option<crate::runtime::HistogramBuilder>,
52
53    #[cfg(tokio_unstable)]
54    /// How to respond to unhandled task panics.
55    pub(crate) unhandled_panic: crate::runtime::UnhandledPanic,
56
57    /// If `true`, an idle worker is woken whenever a worker thread transitions
58    /// from polling the I/O driver to polling its own tasks (requires
59    /// `tokio_unstable`).
60    pub(crate) enable_eager_driver_handoff: bool,
61}