/rust/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.46.1/src/runtime/context.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use crate::loom::thread::AccessError; |
2 | | use crate::task::coop; |
3 | | |
4 | | use std::cell::Cell; |
5 | | |
6 | | #[cfg(any(feature = "rt", feature = "macros"))] |
7 | | use crate::util::rand::FastRand; |
8 | | |
9 | | cfg_rt! { |
10 | | mod blocking; |
11 | | pub(crate) use blocking::{disallow_block_in_place, try_enter_blocking_region, BlockingRegionGuard}; |
12 | | |
13 | | mod current; |
14 | | pub(crate) use current::{with_current, try_set_current, SetCurrentGuard}; |
15 | | |
16 | | mod runtime; |
17 | | pub(crate) use runtime::{EnterRuntime, enter_runtime}; |
18 | | |
19 | | mod scoped; |
20 | | use scoped::Scoped; |
21 | | |
22 | | use crate::runtime::{scheduler, task::Id}; |
23 | | |
24 | | use std::task::Waker; |
25 | | |
26 | | cfg_taskdump! { |
27 | | use crate::runtime::task::trace; |
28 | | } |
29 | | } |
30 | | |
31 | | cfg_rt_multi_thread! { |
32 | | mod runtime_mt; |
33 | | pub(crate) use runtime_mt::{current_enter_context, exit_runtime}; |
34 | | } |
35 | | |
36 | | struct Context { |
37 | | /// Uniquely identifies the current thread |
38 | | #[cfg(feature = "rt")] |
39 | | thread_id: Cell<Option<ThreadId>>, |
40 | | |
41 | | /// Handle to the runtime scheduler running on the current thread. |
42 | | #[cfg(feature = "rt")] |
43 | | current: current::HandleCell, |
44 | | |
45 | | /// Handle to the scheduler's internal "context" |
46 | | #[cfg(feature = "rt")] |
47 | | scheduler: Scoped<scheduler::Context>, |
48 | | |
49 | | #[cfg(feature = "rt")] |
50 | | current_task_id: Cell<Option<Id>>, |
51 | | |
52 | | /// Tracks if the current thread is currently driving a runtime. |
53 | | /// Note, that if this is set to "entered", the current scheduler |
54 | | /// handle may not reference the runtime currently executing. This |
55 | | /// is because other runtime handles may be set to current from |
56 | | /// within a runtime. |
57 | | #[cfg(feature = "rt")] |
58 | | runtime: Cell<EnterRuntime>, |
59 | | |
60 | | #[cfg(any(feature = "rt", feature = "macros"))] |
61 | | rng: Cell<Option<FastRand>>, |
62 | | |
63 | | /// Tracks the amount of "work" a task may still do before yielding back to |
64 | | /// the scheduler |
65 | | budget: Cell<coop::Budget>, |
66 | | |
67 | | #[cfg(all( |
68 | | tokio_unstable, |
69 | | tokio_taskdump, |
70 | | feature = "rt", |
71 | | target_os = "linux", |
72 | | any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64") |
73 | | ))] |
74 | | trace: trace::Context, |
75 | | } |
76 | | |
77 | | tokio_thread_local! { |
78 | | static CONTEXT: Context = const { |
79 | | Context { |
80 | | #[cfg(feature = "rt")] |
81 | | thread_id: Cell::new(None), |
82 | | |
83 | | // Tracks the current runtime handle to use when spawning, |
84 | | // accessing drivers, etc... |
85 | | #[cfg(feature = "rt")] |
86 | | current: current::HandleCell::new(), |
87 | | |
88 | | // Tracks the current scheduler internal context |
89 | | #[cfg(feature = "rt")] |
90 | | scheduler: Scoped::new(), |
91 | | |
92 | | #[cfg(feature = "rt")] |
93 | | current_task_id: Cell::new(None), |
94 | | |
95 | | // Tracks if the current thread is currently driving a runtime. |
96 | | // Note, that if this is set to "entered", the current scheduler |
97 | | // handle may not reference the runtime currently executing. This |
98 | | // is because other runtime handles may be set to current from |
99 | | // within a runtime. |
100 | | #[cfg(feature = "rt")] |
101 | | runtime: Cell::new(EnterRuntime::NotEntered), |
102 | | |
103 | | #[cfg(any(feature = "rt", feature = "macros"))] |
104 | | rng: Cell::new(None), |
105 | | |
106 | | budget: Cell::new(coop::Budget::unconstrained()), |
107 | | |
108 | | #[cfg(all( |
109 | | tokio_unstable, |
110 | | tokio_taskdump, |
111 | | feature = "rt", |
112 | | target_os = "linux", |
113 | | any( |
114 | | target_arch = "aarch64", |
115 | | target_arch = "x86", |
116 | | target_arch = "x86_64" |
117 | | ) |
118 | | ))] |
119 | | trace: trace::Context::new(), |
120 | | } |
121 | | } |
122 | | } |
123 | | |
124 | | #[cfg(any(feature = "macros", all(feature = "sync", feature = "rt")))] |
125 | 0 | pub(crate) fn thread_rng_n(n: u32) -> u32 { |
126 | 0 | CONTEXT.with(|ctx| { |
127 | 0 | let mut rng = ctx.rng.get().unwrap_or_else(FastRand::new); |
128 | 0 | let ret = rng.fastrand_n(n); |
129 | 0 | ctx.rng.set(Some(rng)); |
130 | 0 | ret |
131 | 0 | }) |
132 | 0 | } |
133 | | |
134 | 2.81M | pub(crate) fn budget<R>(f: impl FnOnce(&Cell<coop::Budget>) -> R) -> Result<R, AccessError> { |
135 | 2.81M | CONTEXT.try_with(|ctx| f(&ctx.budget)) tokio::runtime::context::budget::<core::task::poll::Poll<tokio::task::coop::RestoreOnPending>, tokio::task::coop::poll_proceed::{closure#0}>::{closure#0} Line | Count | Source | 135 | 35.8k | CONTEXT.try_with(|ctx| f(&ctx.budget)) |
tokio::runtime::context::budget::<tokio::task::coop::Budget, tokio::task::coop::stop::{closure#0}>::{closure#0} Line | Count | Source | 135 | 521k | CONTEXT.try_with(|ctx| f(&ctx.budget)) |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::result::Result<alloc::boxed::Box<tokio::runtime::scheduler::multi_thread::worker::Core>, ()>, <tokio::runtime::scheduler::multi_thread::worker::Context>::run_task::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), tokio::sync::oneshot::error::RecvError>>, <tokio::runtime::context::blocking::BlockingRegionGuard>::block_on_timeout<&mut tokio::sync::oneshot::Receiver<()>>::{closure#1}>::{closure#0}>::{closure#0} tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), tokio::sync::oneshot::error::RecvError>>, <tokio::runtime::park::CachedParkThread>::block_on<&mut tokio::sync::oneshot::Receiver<()>>::{closure#0}>::{closure#0}>::{closure#0} Line | Count | Source | 135 | 35.8k | CONTEXT.try_with(|ctx| f(&ctx.budget)) |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::task::local::LocalSet>::tick::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<bool, tokio::task::coop::has_budget_remaining::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<(), tokio::task::coop::set::{closure#0}>::{closure#0} tokio::runtime::context::budget::<(), <tokio::task::coop::with_budget::ResetGuard as core::ops::drop::Drop>::drop::{closure#0}>::{closure#0} Line | Count | Source | 135 | 1.12M | CONTEXT.try_with(|ctx| f(&ctx.budget)) |
tokio::runtime::context::budget::<(), <tokio::task::coop::RestoreOnPending as core::ops::drop::Drop>::drop::{closure#0}>::{closure#0} Line | Count | Source | 135 | 19.5k | CONTEXT.try_with(|ctx| f(&ctx.budget)) |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::option::Option<()>>, <tokio::runtime::park::CachedParkThread>::block_on<core::future::poll_fn::PollFn<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>::{closure#0}::{closure#0}>>::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::option::Option<()>>, <tokio::runtime::park::CachedParkThread>::block_on<core::future::poll_fn::PollFn<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<fuzz_client::fuzz_entry::{closure#0}>::{closure#0}::{closure#0}>>::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<()>, <tokio::runtime::park::CachedParkThread>::block_on<core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>::{closure#0}>::{closure#0}>::{closure#0} tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<()>, <tokio::runtime::park::CachedParkThread>::block_on<fuzz_client::fuzz_entry::{closure#0}>::{closure#0}>::{closure#0}>::{closure#0} Line | Count | Source | 135 | 4.62k | CONTEXT.try_with(|ctx| f(&ctx.budget)) |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<()>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>>::{closure#0}::{closure#0}::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<()>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_client::fuzz_entry::{closure#0}>>::{closure#0}::{closure#0}::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>>::{closure#0}::{closure#1}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_client::fuzz_entry::{closure#0}>>::{closure#0}::{closure#1}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::option::Option<core::result::Result<(), h2::error::Error>>>, <tokio::runtime::park::CachedParkThread>::block_on<core::future::poll_fn::PollFn<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>::{closure#0}::{closure#0}>>::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::option::Option<core::result::Result<(), h2::error::Error>>>, <tokio::runtime::park::CachedParkThread>::block_on<core::future::poll_fn::PollFn<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<fuzz_e2e::run::{closure#0}>::{closure#0}::{closure#0}>>::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), h2::error::Error>>, <tokio::runtime::park::CachedParkThread>::block_on<core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>::{closure#0}>::{closure#0}>::{closure#0} tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), h2::error::Error>>, <tokio::runtime::park::CachedParkThread>::block_on<fuzz_e2e::run::{closure#0}>::{closure#0}>::{closure#0}>::{closure#0} Line | Count | Source | 135 | 1.07M | CONTEXT.try_with(|ctx| f(&ctx.budget)) |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), h2::error::Error>>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>>::{closure#0}::{closure#0}::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), h2::error::Error>>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_e2e::run::{closure#0}>>::{closure#0}::{closure#0}::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>>::{closure#0}::{closure#1}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_e2e::run::{closure#0}>>::{closure#0}::{closure#1}>::{closure#0}>::{closure#0} |
136 | 2.81M | } tokio::runtime::context::budget::<core::task::poll::Poll<tokio::task::coop::RestoreOnPending>, tokio::task::coop::poll_proceed::{closure#0}> Line | Count | Source | 134 | 35.8k | pub(crate) fn budget<R>(f: impl FnOnce(&Cell<coop::Budget>) -> R) -> Result<R, AccessError> { | 135 | 35.8k | CONTEXT.try_with(|ctx| f(&ctx.budget)) | 136 | 35.8k | } |
tokio::runtime::context::budget::<tokio::task::coop::Budget, tokio::task::coop::stop::{closure#0}> Line | Count | Source | 134 | 521k | pub(crate) fn budget<R>(f: impl FnOnce(&Cell<coop::Budget>) -> R) -> Result<R, AccessError> { | 135 | 521k | CONTEXT.try_with(|ctx| f(&ctx.budget)) | 136 | 521k | } |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::result::Result<alloc::boxed::Box<tokio::runtime::scheduler::multi_thread::worker::Core>, ()>, <tokio::runtime::scheduler::multi_thread::worker::Context>::run_task::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), tokio::sync::oneshot::error::RecvError>>, <tokio::runtime::context::blocking::BlockingRegionGuard>::block_on_timeout<&mut tokio::sync::oneshot::Receiver<()>>::{closure#1}>::{closure#0}> tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), tokio::sync::oneshot::error::RecvError>>, <tokio::runtime::park::CachedParkThread>::block_on<&mut tokio::sync::oneshot::Receiver<()>>::{closure#0}>::{closure#0}> Line | Count | Source | 134 | 35.8k | pub(crate) fn budget<R>(f: impl FnOnce(&Cell<coop::Budget>) -> R) -> Result<R, AccessError> { | 135 | 35.8k | CONTEXT.try_with(|ctx| f(&ctx.budget)) | 136 | 35.8k | } |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::task::local::LocalSet>::tick::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<bool, tokio::task::coop::has_budget_remaining::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<(), tokio::task::coop::set::{closure#0}> tokio::runtime::context::budget::<(), <tokio::task::coop::with_budget::ResetGuard as core::ops::drop::Drop>::drop::{closure#0}> Line | Count | Source | 134 | 1.12M | pub(crate) fn budget<R>(f: impl FnOnce(&Cell<coop::Budget>) -> R) -> Result<R, AccessError> { | 135 | 1.12M | CONTEXT.try_with(|ctx| f(&ctx.budget)) | 136 | 1.12M | } |
tokio::runtime::context::budget::<(), <tokio::task::coop::RestoreOnPending as core::ops::drop::Drop>::drop::{closure#0}> Line | Count | Source | 134 | 19.5k | pub(crate) fn budget<R>(f: impl FnOnce(&Cell<coop::Budget>) -> R) -> Result<R, AccessError> { | 135 | 19.5k | CONTEXT.try_with(|ctx| f(&ctx.budget)) | 136 | 19.5k | } |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::option::Option<()>>, <tokio::runtime::park::CachedParkThread>::block_on<core::future::poll_fn::PollFn<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>::{closure#0}::{closure#0}>>::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::option::Option<()>>, <tokio::runtime::park::CachedParkThread>::block_on<core::future::poll_fn::PollFn<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<fuzz_client::fuzz_entry::{closure#0}>::{closure#0}::{closure#0}>>::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<()>, <tokio::runtime::park::CachedParkThread>::block_on<core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>::{closure#0}>::{closure#0}> tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<()>, <tokio::runtime::park::CachedParkThread>::block_on<fuzz_client::fuzz_entry::{closure#0}>::{closure#0}>::{closure#0}> Line | Count | Source | 134 | 4.62k | pub(crate) fn budget<R>(f: impl FnOnce(&Cell<coop::Budget>) -> R) -> Result<R, AccessError> { | 135 | 4.62k | CONTEXT.try_with(|ctx| f(&ctx.budget)) | 136 | 4.62k | } |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<()>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>>::{closure#0}::{closure#0}::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<()>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_client::fuzz_entry::{closure#0}>>::{closure#0}::{closure#0}::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>>::{closure#0}::{closure#1}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_client::fuzz_entry::{closure#0}>>::{closure#0}::{closure#1}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::option::Option<core::result::Result<(), h2::error::Error>>>, <tokio::runtime::park::CachedParkThread>::block_on<core::future::poll_fn::PollFn<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>::{closure#0}::{closure#0}>>::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::option::Option<core::result::Result<(), h2::error::Error>>>, <tokio::runtime::park::CachedParkThread>::block_on<core::future::poll_fn::PollFn<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<fuzz_e2e::run::{closure#0}>::{closure#0}::{closure#0}>>::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), h2::error::Error>>, <tokio::runtime::park::CachedParkThread>::block_on<core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>::{closure#0}>::{closure#0}> tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), h2::error::Error>>, <tokio::runtime::park::CachedParkThread>::block_on<fuzz_e2e::run::{closure#0}>::{closure#0}>::{closure#0}> Line | Count | Source | 134 | 1.07M | pub(crate) fn budget<R>(f: impl FnOnce(&Cell<coop::Budget>) -> R) -> Result<R, AccessError> { | 135 | 1.07M | CONTEXT.try_with(|ctx| f(&ctx.budget)) | 136 | 1.07M | } |
Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), h2::error::Error>>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>>::{closure#0}::{closure#0}::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<core::task::poll::Poll<core::result::Result<(), h2::error::Error>>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_e2e::run::{closure#0}>>::{closure#0}::{closure#0}::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>>::{closure#0}::{closure#1}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::budget::<tokio::task::coop::with_budget::ResetGuard, tokio::task::coop::with_budget<(), <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_e2e::run::{closure#0}>>::{closure#0}::{closure#1}>::{closure#0}> |
137 | | |
138 | | cfg_rt! { |
139 | | use crate::runtime::ThreadId; |
140 | | |
141 | 0 | pub(crate) fn thread_id() -> Result<ThreadId, AccessError> { |
142 | 0 | CONTEXT.try_with(|ctx| { |
143 | 0 | match ctx.thread_id.get() { |
144 | 0 | Some(id) => id, |
145 | | None => { |
146 | 0 | let id = ThreadId::next(); |
147 | 0 | ctx.thread_id.set(Some(id)); |
148 | 0 | id |
149 | | } |
150 | | } |
151 | 0 | }) |
152 | 0 | } |
153 | | |
154 | 4.17M | pub(crate) fn set_current_task_id(id: Option<Id>) -> Option<Id> { |
155 | 4.17M | CONTEXT.try_with(|ctx| ctx.current_task_id.replace(id)).unwrap_or(None) |
156 | 4.17M | } |
157 | | |
158 | 0 | pub(crate) fn current_task_id() -> Option<Id> { |
159 | 0 | CONTEXT.try_with(|ctx| ctx.current_task_id.get()).unwrap_or(None) |
160 | 0 | } |
161 | | |
162 | | #[track_caller] |
163 | 0 | pub(crate) fn defer(waker: &Waker) { |
164 | 0 | with_scheduler(|maybe_scheduler| { |
165 | 0 | if let Some(scheduler) = maybe_scheduler { |
166 | 0 | scheduler.defer(waker); |
167 | 0 | } else { |
168 | 0 | // Called from outside of the runtime, immediately wake the |
169 | 0 | // task. |
170 | 0 | waker.wake_by_ref(); |
171 | 0 | } |
172 | 0 | }); |
173 | 0 | } |
174 | | |
175 | 521k | pub(super) fn set_scheduler<R>(v: &scheduler::Context, f: impl FnOnce() -> R) -> R { |
176 | 521k | CONTEXT.with(|c| c.scheduler.set(v, f)) Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, ()), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CurrentThread>::shutdown::{closure#1}, ()>::{closure#0}>::{closure#0} tokio::runtime::context::set_scheduler::<(), tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure#0}>::{closure#0} Line | Count | Source | 176 | 521k | CONTEXT.with(|c| c.scheduler.set(v, f)) |
Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>>::{closure#0}, core::option::Option<()>>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_client::fuzz_entry::{closure#0}>>::{closure#0}, core::option::Option<()>>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<core::result::Result<(), h2::error::Error>>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>>::{closure#0}, core::option::Option<core::result::Result<(), h2::error::Error>>>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<core::result::Result<(), h2::error::Error>>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_e2e::run::{closure#0}>>::{closure#0}, core::option::Option<core::result::Result<(), h2::error::Error>>>::{closure#0}>::{closure#0} |
177 | 521k | } Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, ()), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CurrentThread>::shutdown::{closure#1}, ()>::{closure#0}> tokio::runtime::context::set_scheduler::<(), tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure#0}> Line | Count | Source | 175 | 521k | pub(super) fn set_scheduler<R>(v: &scheduler::Context, f: impl FnOnce() -> R) -> R { | 176 | 521k | CONTEXT.with(|c| c.scheduler.set(v, f)) | 177 | 521k | } |
Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_client::fuzz_entry::{closure#0}>>>>::{closure#0}, core::option::Option<()>>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_client::fuzz_entry::{closure#0}>>::{closure#0}, core::option::Option<()>>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<core::result::Result<(), h2::error::Error>>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut core::pin::Pin<alloc::boxed::Box<fuzz_e2e::run::{closure#0}>>>>::{closure#0}, core::option::Option<core::result::Result<(), h2::error::Error>>>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<core::result::Result<(), h2::error::Error>>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut fuzz_e2e::run::{closure#0}>>::{closure#0}, core::option::Option<core::result::Result<(), h2::error::Error>>>::{closure#0}> |
178 | | |
179 | | #[track_caller] |
180 | 0 | pub(super) fn with_scheduler<R>(f: impl FnOnce(Option<&scheduler::Context>) -> R) -> R { |
181 | 0 | let mut f = Some(f); |
182 | 0 | CONTEXT.try_with(|c| { |
183 | 0 | let f = f.take().unwrap(); |
184 | 0 | if matches!(c.runtime.get(), EnterRuntime::Entered { .. }) { |
185 | 0 | c.scheduler.with(f) |
186 | | } else { |
187 | 0 | f(None) |
188 | | } |
189 | 0 | }) Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::scheduler::multi_thread::worker::with_current<(), <tokio::runtime::scheduler::multi_thread::handle::Handle>::schedule_task::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::scheduler::multi_thread::worker::with_current<(), <tokio::runtime::scheduler::multi_thread::worker::block_in_place::Reset as core::ops::drop::Drop>::drop::{closure#0}>::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::context::defer::{closure#0}>::{closure#0} Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), <alloc::sync::Arc<tokio::runtime::scheduler::current_thread::Handle> as tokio::runtime::task::Schedule>::schedule::{closure#0}>::{closure#0} |
190 | 0 | .unwrap_or_else(|_| (f.take().unwrap())(None)) Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::scheduler::multi_thread::worker::with_current<(), <tokio::runtime::scheduler::multi_thread::handle::Handle>::schedule_task::{closure#0}>::{closure#0}>::{closure#1} Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::scheduler::multi_thread::worker::with_current<(), <tokio::runtime::scheduler::multi_thread::worker::block_in_place::Reset as core::ops::drop::Drop>::drop::{closure#0}>::{closure#0}>::{closure#1} Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::context::defer::{closure#0}>::{closure#1} Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), <alloc::sync::Arc<tokio::runtime::scheduler::current_thread::Handle> as tokio::runtime::task::Schedule>::schedule::{closure#0}>::{closure#1} |
191 | 0 | } Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::scheduler::multi_thread::worker::with_current<(), <tokio::runtime::scheduler::multi_thread::handle::Handle>::schedule_task::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::scheduler::multi_thread::worker::with_current<(), <tokio::runtime::scheduler::multi_thread::worker::block_in_place::Reset as core::ops::drop::Drop>::drop::{closure#0}>::{closure#0}> Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), tokio::runtime::context::defer::{closure#0}> Unexecuted instantiation: tokio::runtime::context::with_scheduler::<(), <alloc::sync::Arc<tokio::runtime::scheduler::current_thread::Handle> as tokio::runtime::task::Schedule>::schedule::{closure#0}> |
192 | | |
193 | | cfg_taskdump! { |
194 | | /// SAFETY: Callers of this function must ensure that trace frames always |
195 | | /// form a valid linked list. |
196 | | pub(crate) unsafe fn with_trace<R>(f: impl FnOnce(&trace::Context) -> R) -> Option<R> { |
197 | | CONTEXT.try_with(|c| f(&c.trace)).ok() |
198 | | } |
199 | | } |
200 | | } |