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 /// How big to make each worker's local queue
16 pub(crate) local_queue_capacity: usize,
17
18 /// Callback for a worker parking itself
19 pub(crate) before_park: Option<Callback>,
20
21 /// Callback for a worker unparking itself
22 pub(crate) after_unpark: Option<Callback>,
23
24 /// To run before each task is spawned.
25 pub(crate) before_spawn: Option<TaskCallback>,
26
27 /// To run after each task is terminated.
28 pub(crate) after_termination: Option<TaskCallback>,
29
30 /// To run before each poll
31 #[cfg(tokio_unstable)]
32 pub(crate) before_poll: Option<TaskCallback>,
33
34 /// To run after each poll
35 #[cfg(tokio_unstable)]
36 pub(crate) after_poll: Option<TaskCallback>,
37
38 /// The multi-threaded scheduler includes a per-worker LIFO slot used to
39 /// store the last scheduled task. This can improve certain usage patterns,
40 /// especially message passing between tasks. However, this LIFO slot is not
41 /// currently stealable.
42 ///
43 /// Eventually, the LIFO slot **will** become stealable, however as a
44 /// stop-gap, this unstable option lets users disable the LIFO task.
45 pub(crate) disable_lifo_slot: bool,
46
47 /// Random number generator seed to configure runtimes to act in a
48 /// deterministic way.
49 pub(crate) seed_generator: RngSeedGenerator,
50
51 /// How to build poll time histograms
52 pub(crate) metrics_poll_count_histogram: Option<crate::runtime::HistogramBuilder>,
53
54 #[cfg(tokio_unstable)]
55 /// How to respond to unhandled task panics.
56 pub(crate) unhandled_panic: crate::runtime::UnhandledPanic,
57}