id
stringlengths
22
133
text
stringlengths
40
40.2k
arch
stringclasses
1 value
syntax
stringclasses
1 value
kind
stringclasses
4 values
repo
stringclasses
27 values
path
stringlengths
5
116
license
stringclasses
6 values
commit
stringlengths
40
40
source_host
stringclasses
1 value
category
stringclasses
16 values
source_url
stringlengths
85
196
line_start
int64
1
4.28k
line_end
int64
4
4.31k
tokio-rs/tokio:tokio/src/runtime/scheduler/block_in_place.rs:1
use crate::runtime::scheduler; #[track_caller] pub(crate) fn block_in_place<F, R>(f: F) -> R where F: FnOnce() -> R, { #[cfg(tokio_unstable)] { use crate::runtime::{Handle, RuntimeFlavor::MultiThreadAlt}; match Handle::try_current().map(|h| h.runtime_flavor()) { Ok(MultiThreadA...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/block_in_place.rs
MIT
4165601b1bbaa7c29cbfb319fe75a9adddf4085e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/src/runtime/scheduler/block_in_place.rs
1
21
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("CurrentThread").finish() } } // ===== impl Core ===== impl Core { /// Get and increment the current tick fn tick(&mut self) { self.tick = self.tick.wrapping_add(1); } fn next_task(&mut self, handle: &Ha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9
} fn submit_metrics(&mut self, handle: &Handle) { self.metrics.submit(&handle.shared.worker_metrics); } } #[cfg(tokio_taskdump)] fn wake_deferred_tasks_and_free(context: &Context) { let wakers = context.defer.take_deferred(); for waker in wakers { waker.wake(); } } // ===== impl C...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13
// Avoid double borrow panic drop(maybe_core); // Taking a taskdump could wakes every task, but we probably don't want // the `yield_now` vector to be that large under normal circumstances. // Therefore, we free its allocation. wake_deferred_tasks_and_free(co...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14
pub(crate) fn worker_metrics(&self, worker: usize) -> &WorkerMetrics { assert_eq!(0, worker); &self.shared.worker_metrics } pub(crate) fn num_blocking_threads(&self) -> usize { self.blocking_spawner.num_threads() } pub(crate) fn num_idle_blocking_thr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15
impl Schedule for Arc<Handle> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { self.shared.owned.remove(task) } fn schedule(&self, task: task::Notified<Self>) { use scheduler::Context::CurrentThread; context::with_scheduler(|maybe_cx| match maybe_cx { Some...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16
// This hook is only called from within the runtime, so // `context::with_scheduler` should match with `&self`, i.e. // there is no opportunity for a nested scheduler to be // called. context::with_scheduler(|maybe_cx| match maybe_cx { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
601
660
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:17
context: scheduler::Context, scheduler: &'a CurrentThread, } impl CoreGuard<'_> { #[track_caller] fn block_on<F: Future>(self, future: F) -> F::Output { let ret = self.enter(|mut core, context| { let waker = Handle::waker_ref(&context.handle); let mut cx = std::task::Context...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
641
700
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:18
let task = match entry { Some(entry) => entry, None => { core.metrics.end_processing_scheduled_tasks(); core = if !context.defer.is_empty() { context.park_yield(core, handle) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
681
740
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:19
// `block_on` panicked. panic!("a spawned task panicked and the runtime is configured to shut down on unhandled panic"); } } } /// Enters the scheduler context. This sets the queue and other necessary /// scheduler state in the thread-local. fn enter<F, R>(self, f: F...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/runtime/scheduler/current_thread.rs
721
760
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14
pub(crate) fn worker_metrics(&self, worker: usize) -> &WorkerMetrics { assert_eq!(0, worker); &self.shared.worker_metrics } pub(crate) fn num_blocking_threads(&self) -> usize { self.blocking_spawner.num_threads() } pub(crate) fn num_idle_blocking_thr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
1204da730000f2eab19d2c05eea12ee3071b3f31
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/runtime/scheduler/current_thread.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15
Some(CurrentThread(cx)) if Arc::ptr_eq(self, &cx.handle) => { let mut core = cx.core.borrow_mut(); // If `None`, the runtime is shutting down, so there is no need // to schedule the task. if let Some(core) = core.as_mut() { core.push_t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
1204da730000f2eab19d2c05eea12ee3071b3f31
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/runtime/scheduler/current_thread.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16
if let Some(core) = core.as_mut() { core.unhandled_panic = true; self.shared.owned.close_and_shutdown_all(); } } _ => unreachable!("runtime core not set in CURRENT thread-local"), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
1204da730000f2eab19d2c05eea12ee3071b3f31
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/runtime/scheduler/current_thread.rs
601
660
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:17
pin!(future); core.metrics.start_processing_scheduled_tasks(); 'outer: loop { let handle = &context.handle; if handle.reset_woken() { let (c, res) = context.enter(core, || { crate::runtime::coop::budget(|| future.as_m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
1204da730000f2eab19d2c05eea12ee3071b3f31
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/runtime/scheduler/current_thread.rs
641
700
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:18
core.metrics.start_processing_scheduled_tasks(); // Try polling the `block_on` future next continue 'outer; } }; let task = context.handle.shared.owned.assert_owner(task); let (...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
1204da730000f2eab19d2c05eea12ee3071b3f31
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/runtime/scheduler/current_thread.rs
681
740
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:19
F: FnOnce(Box<Core>, &Context) -> (Box<Core>, R), { let context = self.context.expect_current_thread(); // Remove `core` from `context` to pass into the closure. let core = context.core.borrow_mut().take().expect("core missing"); // Call the closure and place `core` back le...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
1204da730000f2eab19d2c05eea12ee3071b3f31
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/runtime/scheduler/current_thread.rs
721
750
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:4
blocking_spawner: blocking::Spawner, seed_generator: RngSeedGenerator, config: Config, ) -> (CurrentThread, Arc<Handle>) { let worker_metrics = WorkerMetrics::from_config(&config); // Get the configured global queue interval, or use the default. let global_queue_interval = c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
a8b6353535ffa08fc84aee93d315ec4df088c2c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/current_thread.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:5
} #[track_caller] pub(crate) fn block_on<F: Future>(&self, handle: &scheduler::Handle, future: F) -> F::Output { pin!(future); let mut enter = crate::runtime::context::enter_runtime(handle, false); let handle = handle.as_current_thread(); // Attempt to steal the scheduler core...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
a8b6353535ffa08fc84aee93d315ec4df088c2c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/current_thread.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:1
use crate::future::poll_fn; use crate::loom::sync::atomic::AtomicBool; use crate::loom::sync::Arc; use crate::runtime::driver::{self, Driver}; use crate::runtime::scheduler::{self, Defer}; use crate::runtime::task::{self, Inject, JoinHandle, OwnedTasks, Schedule, Task}; use crate::runtime::{blocking, context, Config, M...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c748f4965eae883a2291945116d84cab5d657100
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c748f4965eae883a2291945116d84cab5d657100/tokio/src/runtime/scheduler/current_thread.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:1
use crate::future::poll_fn; use crate::loom::sync::atomic::AtomicBool; use crate::loom::sync::Arc; use crate::runtime::driver::{self, Driver}; use crate::runtime::task::{self, Inject, JoinHandle, OwnedTasks, Schedule, Task}; use crate::runtime::{blocking, context, scheduler, Config}; use crate::runtime::{MetricsBatch, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2
/// Current random number generator seed pub(crate) seed_generator: RngSeedGenerator, } /// Data required for executing the scheduler. The struct is passed around to /// a function that will perform the scheduling work and acts as a capability token. struct Core { /// Scheduler run queue tasks: VecDeque<No...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3
/// Scheduler configuration options config: Config, /// Keeps track of various runtime metrics. scheduler_metrics: SchedulerMetrics, /// This scheduler only has one worker. worker_metrics: WorkerMetrics, } /// Thread-local context. /// /// pub(crate) to store in `runtime::context`. pub(crate) str...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:4
let worker_metrics = WorkerMetrics::from_config(&config); // Get the configured global queue interval, or use the default. let global_queue_interval = config .global_queue_interval .unwrap_or(DEFAULT_GLOBAL_QUEUE_INTERVAL); let handle = Arc::new(Handle { sha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:5
pin!(future); let mut enter = crate::runtime::context::enter_runtime(handle, false); let handle = handle.as_current_thread(); // Attempt to steal the scheduler core and block_on the future if we can // there, otherwise, lets select on a notification that the core is // availabl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6
context: scheduler::Context::CurrentThread(Context { handle: handle.clone(), core: RefCell::new(Some(core)), }), scheduler: self, }) } pub(crate) fn shutdown(&mut self, handle: &scheduler::Handle) { let handle = handle.as_current_thread();...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7
fn shutdown2(mut core: Box<Core>, handle: &Handle) -> Box<Core> { // Drain the OwnedTasks collection. This call also closes the // collection, ensuring that no tasks are ever pushed after this // call returns. handle.shared.owned.close_and_shutdown_all(); // Drain local queue // We already shut...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8
// ===== impl Core ===== impl Core { /// Get and increment the current tick fn tick(&mut self) { self.tick = self.tick.wrapping_add(1); } fn next_task(&mut self, handle: &Handle) -> Option<Notified> { if self.tick % self.global_queue_interval == 0 { handle ....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9
} fn did_defer_tasks() -> bool { context::with_defer(|deferred| !deferred.is_empty()).unwrap() } fn wake_deferred_tasks() { context::with_defer(|deferred| deferred.wake()); } #[cfg(tokio_taskdump)] fn wake_deferred_tasks_and_free() { let wakers = context::with_defer(|deferred| deferred.take_deferred()); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10
#[allow(clippy::redundant_closure)] let (c, _) = self.enter(core, || f()); core = c; } // This check will fail if `before_park` spawns a task for us to run // instead of parking the thread if core.tasks.is_empty() { // Park until the thread is signale...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11
wake_deferred_tasks(); }); core.driver = Some(driver); core } fn enter<R>(&self, core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R) { // Store the scheduler core in the thread-local context // // A drop-guard is employed at a higher level. *self.c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12
handle } /// Capture a snapshot of this runtime's state. #[cfg(all( tokio_unstable, tokio_taskdump, target_os = "linux", any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64") ))] pub(crate) fn dump(&self) -> crate::runtime::Dump { use crat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13
.collect(); }); // Taking a taskdump could wakes every task, but we probably don't want // the `yield_now` vector to be that large under normal circumstances. // Therefore, we free its allocation. wake_deferred_tasks_and_free(); dump::Dump::new(traces) } fn nex...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14
&self.shared.worker_metrics } pub(crate) fn num_blocking_threads(&self) -> usize { self.blocking_spawner.num_threads() } pub(crate) fn num_idle_blocking_threads(&self) -> usize { self.blocking_spawner.num_idle_threads() } pub(crate) fn blocking_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15
// If `None`, the runtime is shutting down, so there is no need // to schedule the task. if let Some(core) = core.as_mut() { core.push_task(self, task); } } _ => { // Track that a task was scheduled from **outsid...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16
self.shared.owned.close_and_shutdown_all(); } } _ => unreachable!("runtime core not set in CURRENT thread-local"), }) } } } } } impl Wake for Handle { fn wake(arc_self: Arc<Self>)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
601
660
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:17
core.metrics.start_processing_scheduled_tasks(); 'outer: loop { let handle = &context.handle; if handle.reset_woken() { let (c, res) = context.enter(core, || { crate::runtime::coop::budget(|| future.as_mut().poll(&mut cx)) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
641
700
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:18
// Try polling the `block_on` future next continue 'outer; } }; let task = context.handle.shared.owned.assert_owner(task); let (c, _) = context.run_task(core, || { task.run(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
681
740
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:19
let context = self.context.expect_current_thread(); // Remove `core` from `context` to pass into the closure. let core = context.core.borrow_mut().take().expect("core missing"); // Call the closure and place `core` back let (core, ret) = context::set_scheduler(&self.context, || f(core,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
79a7e78c0d4ea5f36d74a773b9023df7d6022b27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/current_thread.rs
721
748
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2
/// Current random number generator seed pub(crate) seed_generator: RngSeedGenerator, } /// Data required for executing the scheduler. The struct is passed around to /// a function that will perform the scheduling work and acts as a capability token. struct Core { /// Scheduler run queue tasks: VecDeque<No...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3
/// Keeps track of various runtime metrics. scheduler_metrics: SchedulerMetrics, /// This scheduler only has one worker. worker_metrics: WorkerMetrics, } /// Thread-local context. /// /// pub(crate) to store in `runtime::context`. pub(crate) struct Context { /// Scheduler handle handle: Arc<Handle...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:4
scheduler_metrics: SchedulerMetrics::new(), worker_metrics, }, driver: driver_handle, blocking_spawner, seed_generator, }); let core = AtomicCell::new(Some(Box::new(Core { tasks: VecDeque::with_capacity(INITIAL_CAPACITY), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:5
if let Some(out) = enter .blocking .block_on(poll_fn(|cx| { if notified.as_mut().poll(cx).is_ready() { return Ready(None); } if let Ready(out) = future.as_mut().poll(cx) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6
let core = match self.take_core(handle) { Some(core) => core, None if std::thread::panicking() => return, None => panic!("Oh no! We never placed the Core back, this is a bug!"), }; // Check that the thread-local is not being destroyed let tls_available = cont...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7
handle.shared.inject.close(); // Drain remote queue while let Some(task) = handle.shared.inject.pop() { drop(task); } assert!(handle.shared.owned.is_empty()); // Submit metrics core.submit_metrics(handle); // Shutdown the resource drivers if let Some(driver) = core.driver.as_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8
self.next_local_task(handle) .or_else(|| handle.next_remote_task()) } } fn next_local_task(&mut self, handle: &Handle) -> Option<Notified> { let ret = self.tasks.pop_front(); handle .shared .worker_metrics .set_queue_depth(self.tasks.l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9
for waker in wakers { waker.wake(); } } } // ===== impl Context ===== impl Context { /// Execute the closure with the given scheduler core stored in the /// thread-local context. fn run_task<R>(&self, mut core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R) { core.metr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10
wake_deferred_tasks(); }); core = c; core.metrics.returned_from_park(); } if let Some(f) = &handle.shared.config.after_unpark { // Incorrect lint, the closures are actually different types so `f` // cannot be passed as an argument to `enter`....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11
// Execute the closure while tracking the execution budget let ret = f(); // Take the scheduler core back let core = self.core.borrow_mut().take().expect("core missing"); (core, ret) } } // ===== impl Handle ===== impl Handle { /// Spawns a future onto the `CurrentThread` sche...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12
use task::trace::trace_current_thread; let mut traces = vec![]; // todo: how to make this work outside of a runtime context? context::with_scheduler(|maybe_context| { // drain the local queue let context = if let Some(context) = maybe_context { context.e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13
} fn waker_ref(me: &Arc<Self>) -> WakerRef<'_> { // Set woken to true when enter block_on, ensure outer future // be polled for the first time when enter loop me.shared.woken.store(true, Release); waker_ref(me) } // reset woken to false and return original value pub(cra...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14
} pub(crate) fn active_tasks_count(&self) -> usize { self.shared.owned.active_tasks_count() } } } impl fmt::Debug for Handle { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("current_thread::Handle { ... }").finish() } } // ===== impl Sha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15
self.driver.unpark(); } }); } cfg_unstable! { fn unhandled_panic(&self) { use crate::runtime::UnhandledPanic; match self.shared.config.unhandled_panic { UnhandledPanic::Ignore => { // Do nothing } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16
Wake::wake_by_ref(&arc_self) } /// Wake by reference fn wake_by_ref(arc_self: &Arc<Self>) { arc_self.shared.woken.store(true, Release); arc_self.driver.unpark(); } } // ===== CoreGuard ===== /// Used to ensure we always place the `Core` value back into its slot in /// `CurrentThread`,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
601
660
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:17
} } for _ in 0..handle.shared.config.event_interval { // Make sure we didn't hit an unhandled_panic if core.unhandled_panic { return (core, None); } core.tick(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
641
700
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:18
}); match ret { Some(ret) => ret, None => { // `block_on` panicked. panic!("a spawned task panicked and the runtime is configured to shut down on unhandled panic"); } } } /// Enters the scheduler context. This sets the queue a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
9f9db7da6340a76938427425c57fe781276d4299
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/scheduler/current_thread.rs
681
725
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2
/// Current random number generator seed pub(crate) seed_generator: RngSeedGenerator, } /// Data required for executing the scheduler. The struct is passed around to /// a function that will perform the scheduling work and acts as a capability token. struct Core { /// Scheduler run queue tasks: VecDeque<No...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3
/// Keeps track of various runtime metrics. scheduler_metrics: SchedulerMetrics, /// This scheduler only has one worker. worker_metrics: WorkerMetrics, } /// Thread-local context. struct Context { /// Scheduler handle handle: Arc<Handle>, /// Scheduler core, enabling the holder of `Context` t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:4
config, scheduler_metrics: SchedulerMetrics::new(), worker_metrics, }, driver: driver_handle, blocking_spawner, seed_generator, }); let core = AtomicCell::new(Some(Box::new(Core { tasks: VecDeque::with_capacity(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:5
pin!(notified); if let Some(out) = enter .blocking .block_on(poll_fn(|cx| { if notified.as_mut().poll(cx).is_ready() { return Ready(None); } if let Ready(out) = f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6
let core = match self.take_core(handle) { Some(core) => core, None if std::thread::panicking() => return, None => panic!("Oh no! We never placed the Core back, this is a bug!"), }; core.enter(|mut core, _context| { // Drain the OwnedTasks collection. This...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7
} impl fmt::Debug for CurrentThread { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("CurrentThread").finish() } } // ===== impl Core ===== impl Core { /// Get and increment the current tick fn tick(&mut self) { self.tick = self.tick.wrapping_add(1); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8
.shared .worker_metrics .set_queue_depth(self.tasks.len()); } fn submit_metrics(&mut self, handle: &Handle) { self.metrics.submit(&handle.shared.worker_metrics); } } fn did_defer_tasks() -> bool { context::with_defer(|deferred| !deferred.is_empty()).unwrap() } fn wake_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9
/// Blocks the current thread until an event is received by the driver, /// including I/O events, timer events, ... fn park(&self, mut core: Box<Core>, handle: &Handle) -> Box<Core> { let mut driver = core.driver.take().expect("driver missing"); if let Some(f) = &handle.shared.config.before_par...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10
/// Checks the driver for new events without blocking the thread. fn park_yield(&self, mut core: Box<Core>, handle: &Handle) -> Box<Core> { let mut driver = core.driver.take().expect("driver missing"); core.submit_metrics(handle); let (mut core, _) = self.enter(core, || { drive...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11
where F: crate::future::Future + Send + 'static, F::Output: Send + 'static, { let (handle, notified) = me.shared.owned.bind(future, me.clone(), id); if let Some(notified) = notified { me.schedule(notified); } handle } /// Capture a snapshot of t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12
let local = &mut core.tasks; if self.shared.inject.is_closed() { return; } traces = trace_current_thread(&self.shared.owned, local, &self.shared.inject) .into_iter() .map(dump::Task::new) .collect(); }); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13
&self.shared.scheduler_metrics } pub(crate) fn injection_queue_depth(&self) -> usize { self.shared.inject.len() } pub(crate) fn worker_metrics(&self, worker: usize) -> &WorkerMetrics { assert_eq!(0, worker); &self.shared.worker_metrics } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14
self.shared.owned.remove(task) } fn schedule(&self, task: task::Notified<Self>) { CURRENT.with(|maybe_cx| match maybe_cx { Some(cx) if Arc::ptr_eq(self, &cx.handle) => { let mut core = cx.core.borrow_mut(); // If `None`, the runtime is shutting down, so ther...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15
// If `None`, the runtime is shutting down, so there is no need to signal shutdown if let Some(core) = core.as_mut() { core.unhandled_panic = true; self.shared.owned.close_and_shutdown_all(); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16
let waker = Handle::waker_ref(&context.handle); let mut cx = std::task::Context::from_waker(&waker); pin!(future); 'outer: loop { let handle = &context.handle; if handle.reset_woken() { let (c, res) = context.enter(core, || { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
601
660
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:17
continue 'outer; } }; let task = context.handle.shared.owned.assert_owner(task); let (c, _) = context.run_task(core, || { task.run(); }); core = c; } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
641
698
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:18
*self.context.core.borrow_mut() = Some(core); ret } } impl Drop for CoreGuard<'_> { fn drop(&mut self) { if let Some(core) = self.context.core.borrow_mut().take() { // Replace old scheduler back into the state to allow // other threads to pick it up and drive it. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/src/runtime/scheduler/current_thread.rs
681
698
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:1
use crate::future::poll_fn; use crate::loom::sync::atomic::AtomicBool; use crate::loom::sync::{Arc, Mutex}; use crate::runtime::driver::{self, Driver}; use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, Task}; use crate::runtime::{blocking, context, scheduler, Config}; use crate::runtime::{MetricsBatch,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2
/// Current random number generator seed pub(crate) seed_generator: RngSeedGenerator, } /// Data required for executing the scheduler. The struct is passed around to /// a function that will perform the scheduling work and acts as a capability token. struct Core { /// Scheduler run queue tasks: VecDeque<No...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3
/// Keeps track of various runtime metrics. scheduler_metrics: SchedulerMetrics, /// This scheduler only has one worker. worker_metrics: WorkerMetrics, } /// Thread-local context. struct Context { /// Scheduler handle handle: Arc<Handle>, /// Scheduler core, enabling the holder of `Context` t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:5
pin!(notified); if let Some(out) = enter .blocking .block_on(poll_fn(|cx| { if notified.as_mut().poll(cx).is_ready() { return Ready(None); } if let Ready(out) = f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6
let core = match self.take_core(handle) { Some(core) => core, None if std::thread::panicking() => return, None => panic!("Oh no! We never placed the Core back, this is a bug!"), }; core.enter(|mut core, _context| { // Drain the OwnedTasks collection. This...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7
(core, ()) }); } } impl fmt::Debug for CurrentThread { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("CurrentThread").finish() } } // ===== impl Core ===== impl Core { /// Get and increment the current tick fn tick(&mut self) { self.tick = s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11
where F: crate::future::Future + Send + 'static, F::Output: Send + 'static, { let (handle, notified) = me.shared.owned.bind(future, me.clone(), id); if let Some(notified) = notified { me.schedule(notified); } handle } /// Capture a snapshot of t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12
let local = &mut core.tasks; let mut injection = self.shared.queue.lock(); let injection = if let Some(injection) = injection.as_mut() { injection } else { return; }; traces = trace_current_thread(&self.shared.owned, local, in...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13
} } cfg_metrics! { impl Handle { pub(crate) fn scheduler_metrics(&self) -> &SchedulerMetrics { &self.shared.scheduler_metrics } pub(crate) fn injection_queue_depth(&self) -> usize { // TODO: avoid having to lock. The multi-threaded injection queue // cou...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14
} } impl fmt::Debug for Handle { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("current_thread::Handle { ... }").finish() } } // ===== impl Shared ===== impl Schedule for Arc<Handle> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { self.shared...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15
}); } cfg_unstable! { fn unhandled_panic(&self) { use crate::runtime::UnhandledPanic; match self.shared.config.unhandled_panic { UnhandledPanic::Ignore => { // Do nothing } UnhandledPanic::ShutdownRuntime => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16
arc_self.shared.woken.store(true, Release); arc_self.driver.unpark(); } } // ===== CoreGuard ===== /// Used to ensure we always place the `Core` value back into its slot in /// `CurrentThread`, even if the future panics. struct CoreGuard<'a> { context: Context, scheduler: &'a CurrentThread, } imp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
601
660
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:17
if core.unhandled_panic { return (core, None); } core.tick(); let entry = core.next_task(handle); let task = match entry { Some(entry) => entry, None => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
641
700
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:18
// `block_on` panicked. panic!("a spawned task panicked and the runtime is configured to shut down on unhandled panic"); } } } /// Enters the scheduler context. This sets the queue and other necessary /// scheduler state in the thread-local. fn enter<F, R>(self, f: F...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c88f9bc9300fc12a04a13ac3dde7251b8d960404
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c88f9bc9300fc12a04a13ac3dde7251b8d960404/tokio/src/runtime/scheduler/current_thread.rs
681
716
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:1
use crate::future::poll_fn; use crate::loom::sync::atomic::AtomicBool; use crate::loom::sync::{Arc, Mutex}; use crate::runtime::driver::{self, Driver}; use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, Task}; use crate::runtime::{blocking, context, scheduler, Config}; use crate::runtime::{MetricsBatch,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2
/// Current random number generator seed pub(crate) seed_generator: RngSeedGenerator, } /// Data required for executing the scheduler. The struct is passed around to /// a function that will perform the scheduling work and acts as a capability token. struct Core { /// Scheduler run queue tasks: VecDeque<ta...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3
/// Keeps track of various runtime metrics. scheduler_metrics: SchedulerMetrics, /// This scheduler only has one worker. worker_metrics: WorkerMetrics, } /// Thread-local context. struct Context { /// Scheduler handle handle: Arc<Handle>, /// Scheduler core, enabling the holder of `Context` t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:4
worker_metrics, }, driver: driver_handle, blocking_spawner, seed_generator, }); let core = AtomicCell::new(Some(Box::new(Core { tasks: VecDeque::with_capacity(INITIAL_CAPACITY), tick: 0, driver: Some(driver), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:5
if let Some(out) = enter .blocking .block_on(poll_fn(|cx| { if notified.as_mut().poll(cx).is_ready() { return Ready(None); } if let Ready(out) = future.as_mut().poll(cx) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6
Some(core) => core, None if std::thread::panicking() => return, None => panic!("Oh no! We never placed the Core back, this is a bug!"), }; core.enter(|mut core, _context| { // Drain the OwnedTasks collection. This call also closes the // collection, ensur...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7
} } impl fmt::Debug for CurrentThread { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("CurrentThread").finish() } } // ===== impl Core ===== impl Core { fn pop_task(&mut self, handle: &Handle) -> Option<task::Notified<Arc<Handle>>> { let ret = self.tasks.po...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8
fn wake_deferred_tasks_and_free() { let wakers = context::with_defer(|deferred| deferred.take_deferred()); if let Some(wakers) = wakers { for waker in wakers { waker.wake(); } } } // ===== impl Context ===== impl Context { /// Execute the closure with the given scheduler co...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9
let (c, _) = self.enter(core, || { driver.park(&handle.driver); wake_deferred_tasks(); }); core = c; core.metrics.returned_from_park(); } if let Some(f) = &handle.shared.config.after_unpark { // Incorrect lint, the closure...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10
*self.core.borrow_mut() = Some(core); // Execute the closure while tracking the execution budget let ret = f(); // Take the scheduler core back let core = self.core.borrow_mut().take().expect("core missing"); (core, ret) } } // ===== impl Handle ===== impl Handle { //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11
pub(crate) fn dump(&self) -> crate::runtime::Dump { use crate::runtime::dump; use task::trace::trace_current_thread; let mut traces = vec![]; // todo: how to make this work outside of a runtime context? CURRENT.with(|maybe_context| { // drain the local queue ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12
dump::Dump::new(traces) } fn pop(&self) -> Option<task::Notified<Arc<Handle>>> { match self.shared.queue.lock().as_mut() { Some(queue) => queue.pop_front(), None => None, } } fn waker_ref(me: &Arc<Self>) -> WakerRef<'_> { // Set woken to true when enter ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13
pub(crate) fn worker_metrics(&self, worker: usize) -> &WorkerMetrics { assert_eq!(0, worker); &self.shared.worker_metrics } pub(crate) fn num_blocking_threads(&self) -> usize { self.blocking_spawner.num_threads() } pub(crate) fn num_idle_blocking_thr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14
// If `None`, the runtime is shutting down, so there is no need // to schedule the task. if let Some(core) = core.as_mut() { core.push_task(self, task); } } _ => { // Track that a task was scheduled from **outsid...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/current_thread.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/src/runtime/scheduler/current_thread.rs
521
580