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. However, this LIFO slot is not
38 /// currently stealable.
39 ///
40 /// Eventually, the LIFO slot **will** become stealable, however as a
41 /// stop-gap, this unstable option lets users disable the LIFO task.
42 pub(crate) disable_lifo_slot: bool,
43
44 /// Random number generator seed to configure runtimes to act in a
45 /// deterministic way.
46 pub(crate) seed_generator: RngSeedGenerator,
47
48 /// How to build poll time histograms
49 pub(crate) metrics_poll_count_histogram: Option<crate::runtime::HistogramBuilder>,
50
51 #[cfg(tokio_unstable)]
52 /// How to respond to unhandled task panics.
53 pub(crate) unhandled_panic: crate::runtime::UnhandledPanic,
54}