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/current_thread.rs:9 | core.metrics.returned_from_park();
}
if let Some(f) = &self.handle.shared.config.after_unpark {
// Incorrect lint, the closures are actually different types so `f`
// cannot be passed as an argument to `enter`.
#[allow(clippy::redundant_closure)]
let (c, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 0b92f80a6506c6a89eb998e5f61a33415353bba1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/scheduler/current_thread.rs | 321 | 380 |
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::context::EnterGuard;
use crate::runtime::driver::{self, Driver, Unpark};
use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, Task};
use crate::runtime::{blocking, Config};
use c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2 | pub(crate) struct Handle {
/// Scheduler state shared across threads
shared: Shared,
/// Resource driver handles
pub(crate) driver: driver::Handle,
/// Blocking pool spawner
pub(crate) blocking_spawner: blocking::Spawner,
/// Current random number generator seed
pub(crate) seed_genera... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3 | /// Collection of all active tasks spawned onto this executor.
owned: OwnedTasks<Arc<Handle>>,
/// Unpark the blocked thread.
unpark: Unpark,
/// Indicates whether the blocked on thread was woken.
woken: AtomicBool,
/// Scheduler configuration options
config: Config,
/// Keeps track ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:4 | blocking_spawner: blocking::Spawner,
seed_generator: RngSeedGenerator,
config: Config,
) -> CurrentThread {
let unpark = driver.unpark();
let handle = Arc::new(Handle {
shared: Shared {
queue: Mutex::new(Some(VecDeque::with_capacity(INITIAL_CAPACITY))),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/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, future: F) -> F::Output {
pin!(future);
// 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
// available or the future is complete.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6 | Some(CoreGuard {
context: Context {
handle: self.handle.clone(),
core: RefCell::new(Some(core)),
},
scheduler: self,
})
}
pub(crate) fn set_context_guard(&mut self, guard: EnterGuard) {
self.context_guard = Some(guard);
}
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7 | // Using `Option::take` to replace the shared queue with `None`.
// We already shut down every task, so we just need to drop the task.
if let Some(remote_queue) = remote_queue {
for task in remote_queue {
drop(task);
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8 | fn push_task(&mut self, handle: &Handle, task: task::Notified<Arc<Handle>>) {
self.tasks.push_back(task);
self.metrics.inc_local_schedule_count();
handle
.shared
.worker_metrics
.set_queue_depth(self.tasks.len());
}
}
// ===== impl Context =====
impl Con... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/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();
});
core = c;
core.metrics.returned_from_park();
}
if let Some(f) = &self.handle.shared.config.after_unpark {
// Incorrect lint, the closures are actually different types so `f`
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10 | // 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 | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11 | // 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(crate) fn reset_woken(&self) -> bool {
self.shared.woken.swap(false, AcqRel)
}
}
cfg_metrics! {
impl Handle {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12 | // ===== impl Shared =====
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>) {
CURRENT.with(|maybe_cx| match maybe_cx {
Some(cx) if Arc::ptr_eq(self, &cx.h... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13 | UnhandledPanic::Ignore => {
// Do nothing
}
UnhandledPanic::ShutdownRuntime => {
// This hook is only called from within the runtime, so
// `CURRENT` should match with `&self`, i.e. there is no
// opportunity... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14 | /// `CurrentThread`, even if the future panics.
struct CoreGuard<'a> {
context: 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 _enter = crate::runtime... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15 | let entry = if tick % handle.shared.config.global_queue_interval == 0 {
handle.pop().or_else(|| core.tasks.pop_front())
} else {
core.tasks.pop_front().or_else(|| handle.pop())
};
let task = match entry {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16 | /// Enters the scheduler context. This sets the queue and other necessary
/// scheduler state in the thread-local.
fn enter<F, R>(self, f: F) -> R
where
F: FnOnce(Box<Core>, &Context) -> (Box<Core>, R),
{
// Remove `core` from `context` to pass into the closure.
let core = self.c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/scheduler/current_thread.rs | 601 | 631 |
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::context::EnterGuard;
use crate::runtime::driver::{self, Driver, Unpark};
use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, Task};
use crate::runtime::{blocking, Config};
use c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2 | #[derive(Debug)]
pub(crate) struct Handle {
/// Task spawner
pub(crate) spawner: Spawner,
/// Resource driver handles
pub(crate) driver: driver::Handle,
/// Blocking pool spawner
pub(crate) blocking_spawner: blocking::Spawner,
/// Current random number generator seed
pub(crate) seed_g... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3 | #[derive(Clone)]
pub(crate) struct Spawner {
shared: Arc<Shared>,
}
/// Scheduler state shared between threads.
struct Shared {
/// Remote run queue. None if the `Runtime` has been dropped.
queue: Mutex<Option<VecDeque<task::Notified<Arc<Shared>>>>>,
/// Collection of all active tasks spawned onto thi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:4 | const INITIAL_CAPACITY: usize = 64;
// Tracks the current CurrentThread.
scoped_thread_local!(static CURRENT: Context);
impl CurrentThread {
pub(crate) fn new(driver: Driver, config: Config) -> CurrentThread {
let unpark = driver.unpark();
let spawner = Spawner {
shared: Arc::new(Shar... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/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, future: F) -> F::Output {
pin!(future);
// 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
// available or the future is complete... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6 | Some(CoreGuard {
context: Context {
spawner: self.spawner.clone(),
core: RefCell::new(Some(core)),
},
scheduler: self,
})
}
pub(crate) fn set_context_guard(&mut self, guard: EnterGuard) {
self.context_guard = Some(guard);
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7 | // Using `Option::take` to replace the shared queue with `None`.
// We already shut down every task, so we just need to drop the task.
if let Some(remote_queue) = remote_queue {
for task in remote_queue {
drop(task);
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8 | }
fn push_task(&mut self, task: task::Notified<Arc<Shared>>) {
self.tasks.push_back(task);
self.metrics.inc_local_schedule_count();
self.spawner
.shared
.worker_metrics
.set_queue_depth(self.tasks.len());
}
}
// ===== impl Context =====
impl Context... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9 | core.metrics.submit(&core.spawner.shared.worker_metrics);
let (c, _) = self.enter(core, || {
driver.park();
});
core = c;
core.metrics.returned_from_park();
}
if let Some(f) = &self.spawner.shared.config.after_unpark {
// Inc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10 | // 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 Spawner =====
impl Spawner {
/// Spawns a future onto the `CurrentThread` sc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11 | }
// reset woken to false and return original value
pub(crate) fn reset_woken(&self) -> bool {
self.shared.woken.swap(false, AcqRel)
}
}
cfg_metrics! {
impl Handle {
pub(crate) fn scheduler_metrics(&self) -> &SchedulerMetrics {
&self.spawner.shared.scheduler_metrics
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12 | impl Schedule for Arc<Shared> {
fn release(&self, task: &Task<Self>) -> Option<Task<Self>> {
self.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.spawner.shared) => {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13 | }
UnhandledPanic::ShutdownRuntime => {
// This hook is only called from within the runtime, so
// `CURRENT` should match with `&self`, i.e. there is no
// opportunity for a nested scheduler to be called.
CURRENT.with(|maybe_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14 | context: 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 _enter = crate::runtime::enter(false);
let waker = context.spawner.waker_ref();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15 | core.tasks.pop_front().or_else(|| core.spawner.pop())
};
let task = match entry {
Some(entry) => entry,
None => {
core = context.park(core);
// Try polling the `block_on` fut... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16 | where
F: FnOnce(Box<Core>, &Context) -> (Box<Core>, R),
{
// Remove `core` from `context` to pass into the closure.
let core = self.context.core.borrow_mut().take().expect("core missing");
// Call the closure and place `core` back
let (core, ret) = CURRENT.set(&self.context,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/scheduler/current_thread.rs | 601 | 627 |
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::context::EnterGuard;
use crate::runtime::driver::{Driver, Unpark};
use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, Task};
use crate::runtime::Config;
use crate::runtime::{Me... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2 | /// a function that will perform the scheduling work and acts as a capability token.
struct Core {
/// Scheduler run queue
tasks: VecDeque<task::Notified<Arc<Shared>>>,
/// Sendable task spawner
spawner: Spawner,
/// Current tick
tick: u32,
/// Runtime driver
///
/// The driver is... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3 | /// Indicates whether the blocked on thread was woken.
woken: AtomicBool,
/// Scheduler configuration options
config: Config,
/// Keeps track of various runtime metrics.
scheduler_metrics: SchedulerMetrics,
/// This scheduler only has one worker.
worker_metrics: WorkerMetrics,
}
/// Thre... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/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: WorkerMetrics::new(),
}),
};
let core = AtomicCell::new(Some(Box::new(Core {
tasks: VecDeque::with_capacity(INITIAL_CAPACITY),
spawner: spawner.clone(),
tick: 0,
drive... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/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
.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 | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6 | fn drop(&mut self) {
// Avoid a double panic if we are currently panicking and
// the lock may be poisoned.
let core = match self.take_core() {
Some(core) => core,
None if std::thread::panicking() => return,
None => panic!("Oh no! We never placed the Core bac... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7 | driver.shutdown();
}
(core, ())
});
}
}
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) -> Option<task::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8 | /// thread-local context.
fn run_task<R>(&self, mut core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R) {
core.metrics.incr_poll_count();
self.enter(core, || crate::coop::budget(f))
}
/// Blocks the current thread until an event is received by the driver,
/// including I/O events,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9 | }
core.driver = Some(driver);
core
}
/// Checks the driver for new events without blocking the thread.
fn park_yield(&self, mut core: Box<Core>) -> Box<Core> {
let mut driver = core.driver.take().expect("driver missing");
core.metrics.submit(&core.spawner.shared.worker_met... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10 | F: crate::future::Future + Send + 'static,
F::Output: Send + 'static,
{
let (handle, notified) = self.shared.owned.bind(future, self.shared.clone(), id);
if let Some(notified) = notified {
self.shared.schedule(notified);
}
handle
}
fn pop(&self) -> Opti... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11 | // could probably be used here.
self.shared.queue.lock()
.as_ref()
.map(|queue| queue.len())
.unwrap_or(0)
}
pub(crate) fn worker_metrics(&self, worker: usize) -> &WorkerMetrics {
assert_eq!(0, worker);
&self.shared.wor... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12 | self.scheduler_metrics.inc_remote_schedule_count();
// If the queue is None, then the runtime has shut down. We
// don't need to do anything with the notification in that case.
let mut guard = self.queue.lock();
if let Some(queue) = guard.as_mut() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13 | }
}
}
impl Wake for Shared {
fn wake(arc_self: Arc<Self>) {
Wake::wake_by_ref(&arc_self)
}
/// Wake by reference
fn wake_by_ref(arc_self: &Arc<Self>) {
arc_self.woken.store(true, Release);
arc_self.unpark.unpark();
}
}
// ===== CoreGuard =====
/// Used to ensure we al... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14 | core = c;
if let Ready(v) = res {
return (core, Some(v));
}
}
for _ in 0..core.spawner.shared.config.event_interval {
// Make sure we didn't hit an unhandled_panic
if core.unhandled_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15 | core = c;
}
// Yield to the driver, this drives the timer and pulls any
// pending I/O events.
core = context.park_yield(core);
}
});
match ret {
Some(ret) => ret,
None => {
// `block_on... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 98e642d23477d1af8d7a62d41d9907e567241a71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98e642d23477d1af8d7a62d41d9907e567241a71/tokio/src/runtime/scheduler/current_thread.rs | 561 | 608 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6 | fn drop(&mut self) {
// Avoid a double panic if we are currently panicking and
// the lock may be poisoned.
let core = match self.take_core() {
Some(core) => core,
None if std::thread::panicking() => return,
None => panic!("Oh no! We never placed the Core bac... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/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) -> Option<task::Notified<Arc<Shared>>> {
let ret = self.tasks.pop_front();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8 | /// 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>) -> Box<Core> {
let mut driver = core.driver.take().expect("driver missing");
if let Some(f) = &self.spawner.shared.config.before_park {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9 | /// Checks the driver for new events without blocking the thread.
fn park_yield(&self, mut core: Box<Core>) -> Box<Core> {
let mut driver = core.driver.take().expect("driver missing");
core.metrics.submit(&core.spawner.shared.worker_metrics);
let (mut core, _) = self.enter(core, || {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10 | if let Some(notified) = notified {
self.shared.schedule(notified);
}
handle
}
fn pop(&self) -> Option<task::Notified<Arc<Shared>>> {
match self.shared.queue.lock().as_mut() {
Some(queue) => queue.pop_front(),
None => None,
}
}
fn wak... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11 | }
pub(crate) fn worker_metrics(&self, worker: usize) -> &WorkerMetrics {
assert_eq!(0, worker);
&self.shared.worker_metrics
}
}
}
impl fmt::Debug for Spawner {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Spawner").finish()
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12 | if let Some(queue) = guard.as_mut() {
queue.push_back(task);
drop(guard);
self.unpark.unpark();
}
}
});
}
cfg_unstable! {
fn unhandled_panic(&self) {
use crate::runtime::UnhandledPanic;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13 | fn wake(arc_self: Arc<Self>) {
Wake::wake_by_ref(&arc_self)
}
/// Wake by reference
fn wake_by_ref(arc_self: &Arc<Self>) {
arc_self.woken.store(true, Release);
arc_self.unpark.unpark();
}
}
// ===== CoreGuard =====
/// Used to ensure we always place the `Core` value back into ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14 | }
}
for _ in 0..core.spawner.shared.config.event_interval {
// Make sure we didn't hit an unhandled_panic
if core.unhandled_panic {
return (core, None);
}
// Get and increment the cu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15 | core = context.park_yield(core);
}
});
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");
}
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/scheduler/current_thread.rs | 561 | 603 |
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::context::EnterGuard;
use crate::runtime::driver::{Driver, Unpark};
use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, Task};
use crate::runtime::{Config, HandleInner};
use crat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:2 | /// a function that will perform the scheduling work and acts as a capability token.
struct Core {
/// Scheduler run queue
tasks: VecDeque<task::Notified<Arc<Shared>>>,
/// Sendable task spawner
spawner: Spawner,
/// Current tick
tick: u32,
/// Runtime driver
///
/// The driver is... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:3 | /// Indicates whether the blocked on thread was woken.
woken: AtomicBool,
/// Handle to I/O driver, timer, blocking pool, ...
handle_inner: HandleInner,
/// Scheduler configuration options
config: Config,
/// Keeps track of various runtime metrics.
scheduler_metrics: SchedulerMetrics,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:4 | unpark,
woken: AtomicBool::new(false),
handle_inner,
config,
scheduler_metrics: SchedulerMetrics::new(),
worker_metrics: WorkerMetrics::new(),
}),
};
let core = AtomicCell::new(Some(Box::new(Core {
t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:5 | } else {
let mut enter = crate::runtime::enter(false);
let notified = self.notify.notified();
pin!(notified);
if let Some(out) = enter
.block_on(poll_fn(|cx| {
if notified.as_mut().poll(cx).is_ready() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:6 | }
}
impl Drop for CurrentThread {
fn drop(&mut self) {
// Avoid a double panic if we are currently panicking and
// the lock may be poisoned.
let core = match self.take_core() {
Some(core) => core,
None if std::thread::panicking() => return,
None => pani... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:7 | core.metrics.submit(&core.spawner.shared.worker_metrics);
(core, ())
});
}
}
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(&m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:8 | fn run_task<R>(&self, mut core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R) {
core.metrics.incr_poll_count();
self.enter(core, || crate::coop::budget(f))
}
/// Blocks the current thread until an event is received by the driver,
/// including I/O events, timer events, ...
fn park... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:9 | core.driver = Some(driver);
core
}
/// Checks the driver for new events without blocking the thread.
fn park_yield(&self, mut core: Box<Core>) -> Box<Core> {
let mut driver = core.driver.take().expect("driver missing");
core.metrics.submit(&core.spawner.shared.worker_metrics);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:10 | F::Output: Send + 'static,
{
let (handle, notified) = self.shared.owned.bind(future, self.shared.clone(), id);
if let Some(notified) = notified {
self.shared.schedule(notified);
}
handle
}
fn pop(&self) -> Option<task::Notified<Arc<Shared>>> {
match sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:11 | pub(crate) fn injection_queue_depth(&self) -> usize {
// TODO: avoid having to lock. The multi-threaded injection queue
// could probably be used here.
self.shared.queue.lock()
.as_ref()
.map(|queue| queue.len())
.unwrap_or(0)
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:12 | }
_ => {
// Track that a task was scheduled from **outside** of the runtime.
self.scheduler_metrics.inc_remote_schedule_count();
// If the queue is None, then the runtime has shut down. We
// don't need to do anything with the notification in ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:13 | })
}
}
}
}
}
impl Wake for Shared {
fn wake(arc_self: Arc<Self>) {
Wake::wake_by_ref(&arc_self)
}
/// Wake by reference
fn wake_by_ref(arc_self: &Arc<Self>) {
arc_self.woken.store(true, Release);
arc_self.unpark.unpark();
}
}
// ====... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:14 | let (c, res) = context.enter(core, || {
crate::coop::budget(|| future.as_mut().poll(&mut cx))
});
core = c;
if let Ready(v) = res {
return (core, Some(v));
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:15 | task.run();
});
core = c;
}
// Yield to the driver, this drives the timer and pulls any
// pending I/O events.
core = context.park_yield(core);
}
});
match ret {
Some(ret) =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 561 | 611 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread.rs:16 | 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.
self.scheduler.core.set(core);
// Wake up other possible threads that could steal t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/current_thread.rs | 601 | 611 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:1 | use crate::loom::sync::atomic::AtomicBool;
use crate::loom::sync::Arc;
use crate::runtime::driver::{self, Driver};
use crate::runtime::scheduler::{self, Defer, Inject};
use crate::runtime::task::{
self, JoinHandle, OwnedTasks, Schedule, SpawnLocation, Task, TaskHarnessScheduleHooks,
};
use crate::runtime::{
blo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:2 | shared: Shared,
/// Resource driver handles
pub(crate) driver: driver::Handle,
/// Blocking pool spawner
pub(crate) blocking_spawner: blocking::Spawner,
/// Current random number generator seed
pub(crate) seed_generator: RngSeedGenerator,
/// User-supplied hooks to invoke for things
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:3 | unhandled_panic: bool,
}
/// Scheduler state shared between threads.
struct Shared {
/// Remote run queue
inject: Inject<Arc<Handle>>,
/// Collection of all active tasks spawned onto this executor.
owned: OwnedTasks<Arc<Handle>>,
/// Indicates whether the blocked on thread was woken.
woken: A... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:4 | /// Initial queue capacity.
const INITIAL_CAPACITY: usize = 64;
/// Used if none is specified. This is a temporary constant and will be removed
/// as we unify tuning logic between the multi-thread and current-thread
/// schedulers.
const DEFAULT_GLOBAL_QUEUE_INTERVAL: u32 = 31;
impl CurrentThread {
pub(crate) fn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:5 | woken: AtomicBool::new(false),
config,
scheduler_metrics: SchedulerMetrics::new(),
worker_metrics,
},
driver: driver_handle,
blocking_spawner,
seed_generator,
local_tid,
});
let core = AtomicCell... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:6 | handle
.shared
.worker_metrics
.set_thread_id(thread::current().id());
return core.block_on(future);
} else {
let notified = self.notify.notified();
pin!(notified);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:7 | })
}
pub(crate) fn shutdown(&mut self, handle: &scheduler::Handle) {
let handle = handle.as_current_thread();
// Avoid a double panic if we are currently panicking and
// the lock may be poisoned.
let core = match self.take_core(handle) {
Some(core) => core,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:8 | handle.shared.owned.close_and_shutdown_all(0);
// Drain local queue
// We already shut down every task, so we just need to drop the task.
while let Some(task) = core.next_local_task(handle) {
drop(task);
}
// Close the injection queue
handle.shared.inject.close();
// Drain remote ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:9 | 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
.next_remote_task()
.or_else(|| self.next_local_task(handle))
} else {
self.nex... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:10 | 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.metrics.start_poll... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:11 | if let Some(f) = &handle.shared.config.after_unpark {
let (c, ()) = self.enter(core, || f());
core = c;
}
core.driver = Some(driver);
core
}
/// Checks the driver for new events without blocking the thread.
fn park_yield(&self, mut core: Box<Core>, handle: &... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | 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.core.borrow_mut() = Some(core);
// Execute the closure while tracking th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | id,
spawned_at,
_phantom: Default::default(),
});
if let Some(notified) = notified {
me.schedule(notified);
}
handle
}
/// Spawn a task which isn't safe to send across thread boundaries onto the runtime.
///
/// # Safety
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | _phantom: Default::default(),
});
if let Some(notified) = notified {
me.schedule(notified);
}
handle
}
/// Capture a snapshot of this runtime's state.
#[cfg(all(
tokio_unstable,
feature = "taskdump",
target_os = "linux",
any(targ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | return;
}
traces = trace_current_thread(&self.shared.owned, local, &self.shared.inject)
.into_iter()
.map(|(id, trace)| dump::Task::new(id, trace))
.collect();
// Avoid double borrow panic
drop(maybe_core);
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | 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
}
}
cfg_unstable_metrics! {
impl Handle {
pub(crate) fn scheduler_m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | use std::num::NonZeroU64;
impl Handle {
pub(crate) fn owned_id(&self) -> NonZeroU64 {
self.shared.owned.id
}
pub(crate) fn name(&self) -> Option<&str> {
self.name.as_deref()
}
}
impl fmt::Debug for Handle {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.d... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | self.shared.scheduler_metrics.inc_remote_schedule_count();
// Schedule the task
self.shared.inject.push(task);
self.driver.unpark();
}
});
}
fn hooks(&self) -> TaskHarnessScheduleHooks {
TaskHarnessScheduleHooks {
task_ter... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | _ => unreachable!("runtime core not set in CURRENT thread-local"),
})
}
}
}
}
}
impl Wake for Handle {
fn wake(arc_self: Arc<Self>) {
Wake::wake_by_ref(&arc_self);
}
/// Wake by reference
fn wake_by_ref(arc_self: &Arc<Self>) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | 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::from_waker(&waker);
pin!(future);
core... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:21 | core.metrics.end_processing_scheduled_tasks();
core = if context.has_pending_work(&core) {
context.park_yield(core, handle)
} else {
context.park(core, handle)
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:22 | }
});
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 t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/current_thread/mod.rs | 841 | 886 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:1 | use crate::loom::sync::atomic::AtomicBool;
use crate::loom::sync::Arc;
use crate::runtime::driver::{self, Driver};
use crate::runtime::scheduler::{self, Defer, Inject};
use crate::runtime::task::{
self, JoinHandle, OwnedTasks, Schedule, SpawnLocation, Task, TaskHarnessScheduleHooks,
};
use crate::runtime::{
blo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/tokio/src/runtime/scheduler/current_thread/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:2 | pub(crate) driver: driver::Handle,
/// Blocking pool spawner
pub(crate) blocking_spawner: blocking::Spawner,
/// Current random number generator seed
pub(crate) seed_generator: RngSeedGenerator,
/// User-supplied hooks to invoke for things
pub(crate) task_hooks: TaskHooks,
/// If this is... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/tokio/src/runtime/scheduler/current_thread/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:3 | /// Scheduler state shared between threads.
struct Shared {
/// Remote run queue
inject: Inject<Arc<Handle>>,
/// Collection of all active tasks spawned onto this executor.
owned: OwnedTasks<Arc<Handle>>,
/// Indicates whether the blocked on thread was woken.
woken: AtomicBool,
/// Schedu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/tokio/src/runtime/scheduler/current_thread/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:4 | /// Used if none is specified. This is a temporary constant and will be removed
/// as we unify tuning logic between the multi-thread and current-thread
/// schedulers.
const DEFAULT_GLOBAL_QUEUE_INTERVAL: u32 = 31;
impl CurrentThread {
pub(crate) fn new(
driver: Driver,
driver_handle: driver::Hand... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/tokio/src/runtime/scheduler/current_thread/mod.rs | 121 | 180 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.