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/mod.rs:17 | // to schedule the task.
if let Some(core) = core.as_mut() {
core.push_task(self, task);
}
}
_ => {
// Track that a task was scheduled from **outside** of the runtime.
self.shared.scheduler_metrics.inc_remote_sch... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | // 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(0);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | let waker = Handle::waker_ref(&context.handle);
let mut cx = std::task::Context::from_waker(&waker);
pin!(future);
core.metrics.start_processing_scheduled_tasks();
'outer: loop {
let handle = &context.handle;
if handle.reset_woken() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | context.park(core, handle)
};
core.metrics.start_processing_scheduled_tasks();
// Try polling the `block_on` future next
continue 'outer;
}
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:21 | 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 and other necessary
/// scheduler state in the thread-local.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/src/runtime/scheduler/current_thread/mod.rs | 801 | 841 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | let mut maybe_core = context.core.borrow_mut();
let core = if let Some(core) = maybe_core.as_mut() {
core
} else {
return;
};
let local = &mut core.tasks;
if self.shared.inject.is_closed() {
return;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | // reset woken to false and return original value
pub(crate) fn reset_woken(&self) -> bool {
self.shared.woken.swap(false, AcqRel)
}
pub(crate) fn num_alive_tasks(&self) -> usize {
self.shared.owned.num_alive_tasks()
}
pub(crate) fn injection_queue_depth(&self) -> usize {
s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:9 | handle
.next_remote_task()
.or_else(|| self.next_local_task(handle))
} else {
self.next_local_task(handle)
.or_else(|| handle.next_remote_task())
}
}
fn next_local_task(&mut self, handle: &Handle) -> Option<Notified> {
let ret ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/current_thread/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:10 | // ===== 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();
let mut ret = self.enter(core, || crate::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/current_thread/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | // 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(0);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | let waker = Handle::waker_ref(&context.handle);
let mut cx = std::task::Context::from_waker(&waker);
pin!(future);
core.metrics.start_processing_scheduled_tasks();
'outer: loop {
let handle = &context.handle;
if handle.reset_woken() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
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 | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:5 | });
let core = AtomicCell::new(Some(Box::new(Core {
tasks: VecDeque::with_capacity(INITIAL_CAPACITY),
tick: 0,
driver: Some(driver),
metrics: MetricsBatch::new(&handle.shared.worker_metrics),
global_queue_interval,
unhandled_panic: false,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:6 | if let Some(out) = 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/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:7 | 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/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:8 | 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/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:9 | 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/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:10 | /// thread-local context.
fn run_task<R>(&self, mut core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R) {
core.metrics.start_poll();
let mut ret = self.enter(core, || crate::runtime::coop::budget(f));
ret.0.metrics.end_poll();
ret
}
/// Blocks the current thread until ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:11 | core.driver = Some(driver);
core
}
/// 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 (mu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | impl Handle {
/// Spawns a future onto the `CurrentThread` scheduler
pub(crate) fn spawn<F>(
me: &Arc<Self>,
future: F,
id: crate::runtime::task::Id,
) -> JoinHandle<F::Output>
where
F: crate::future::Future + Send + 'static,
F::Output: Send + 'static,
{
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | {
let (handle, notified) = me.shared.owned.bind_local(future, me.clone(), id);
me.task_hooks.spawn(&TaskMeta {
id,
_phantom: Default::default(),
});
if let Some(notified) = notified {
me.schedule(notified);
}
handle
}
/// Ca... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | return;
};
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(|(id, trace)| dump::Task::ne... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | pub(crate) fn num_alive_tasks(&self) -> usize {
self.shared.owned.num_alive_tasks()
}
pub(crate) fn injection_queue_depth(&self) -> usize {
self.shared.inject.len()
}
}
cfg_unstable_metrics! {
impl Handle {
pub(crate) fn scheduler_metrics(&self) -> &SchedulerMetrics {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | }
}
}
}
cfg_unstable! {
use std::num::NonZeroU64;
impl Handle {
pub(crate) fn owned_id(&self) -> NonZeroU64 {
self.shared.owned.id
}
}
}
impl fmt::Debug for Handle {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("current_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | }
_ => {
// Track that a task was scheduled from **outside** of the runtime.
self.shared.scheduler_metrics.inc_remote_schedule_count();
// Schedule the task
self.shared.inject.push(task);
self.driver.unpark();
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | self.shared.owned.close_and_shutdown_all(0);
}
}
_ => 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/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | 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/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | // 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/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:21 | 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/mod.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/scheduler/current_thread/mod.rs | 801 | 828 |
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, Task, TaskHarnessScheduleHooks,
};
use crate::runtime::{
blocking, context,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:2 | /// 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,
}
/// Data required for executing the scheduler. The struc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:3 | /// Collection of all active tasks spawned onto this executor.
owned: OwnedTasks<Arc<Handle>>,
/// Indicates whether the blocked on thread was woken.
woken: AtomicBool,
/// Scheduler configuration options
config: Config,
/// Keeps track of various runtime metrics.
scheduler_metrics: Sched... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:4 | const DEFAULT_GLOBAL_QUEUE_INTERVAL: u32 = 31;
impl CurrentThread {
pub(crate) fn new(
driver: Driver,
driver_handle: driver::Handle,
blocking_spawner: blocking::Spawner,
seed_generator: RngSeedGenerator,
config: Config,
) -> (CurrentThread, Arc<Handle>) {
let wo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:5 | metrics: MetricsBatch::new(&handle.shared.worker_metrics),
global_queue_interval,
unhandled_panic: false,
})));
let scheduler = CurrentThread {
core,
notify: Notify::new(),
};
(scheduler, handle)
}
#[track_caller]
pub(crate) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:6 | if let Ready(out) = future.as_mut().poll(cx) {
return Ready(Some(out));
}
Pending
}))
.expect("Failed to `Enter::block_on`")
{
return out;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:7 | // Check that the thread-local is not being destroyed
let tls_available = context::with_current(|_| ()).is_ok();
if tls_available {
core.enter(|core, _context| {
let core = shutdown2(core, handle);
(core, ())
});
} else {
// Sh... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:8 | assert!(handle.shared.owned.is_empty());
// Submit metrics
core.submit_metrics(handle);
// Shutdown the resource drivers
if let Some(driver) = core.driver.as_mut() {
driver.shutdown(&handle.driver);
}
core
}
impl fmt::Debug for CurrentThread {
fn fmt(&self, fmt: &mut fmt::Formatt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:9 | let ret = self.tasks.pop_front();
handle
.shared
.worker_metrics
.set_queue_depth(self.tasks.len());
ret
}
fn push_task(&mut self, handle: &Handle, task: Notified) {
self.tasks.push_back(task);
self.metrics.inc_local_schedule_count();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:10 | }
/// 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.bef... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:11 | 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, || {
driver.park_timeout(&handle.driver, Duration::from_millis(0));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | id: crate::runtime::task::Id,
) -> JoinHandle<F::Output>
where
F: crate::future::Future + Send + 'static,
F::Output: Send + 'static,
{
let (handle, notified) = me.shared.owned.bind(future, me.clone(), id);
me.task_hooks.spawn(&TaskMeta {
id,
_phantom:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | };
let mut maybe_core = context.core.borrow_mut();
let core = if let Some(core) = maybe_core.as_mut() {
core
} else {
return;
};
let local = &mut core.tasks;
if self.shared.inject.is_closed() {
retur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | // reset woken to false and return original value
pub(crate) fn reset_woken(&self) -> bool {
self.shared.woken.swap(false, AcqRel)
}
pub(crate) fn num_alive_tasks(&self) -> usize {
self.shared.owned.num_alive_tasks()
}
pub(crate) fn injection_queue_depth(&self) -> usize {
s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | }
cfg_64bit_metrics! {
pub(crate) fn spawned_tasks_count(&self) -> u64 {
self.shared.owned.spawned_tasks_count()
}
}
}
}
cfg_unstable! {
use std::num::NonZeroU64;
impl Handle {
pub(crate) fn owned_id(&self) -> NonZeroU64 {
self.s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | // 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/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | let mut core = cx.core.borrow_mut();
// 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.ow... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | 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.metrics.start_processing_scheduled_tasks();
'outer: loop {
let handle = &conte... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | } else {
context.park(core, handle)
};
core.metrics.start_processing_scheduled_tasks();
// Try polling the `block_on` future next
continue 'outer;
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | /// scheduler state in the thread-local.
fn enter<F, R>(self, f: F) -> R
where
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... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 793 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:11 | 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, || {
driver.park_timeout(&handle.driver, Duration::from_millis(0));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | id: crate::runtime::task::Id,
) -> JoinHandle<F::Output>
where
F: crate::future::Future + Send + 'static,
F::Output: Send + 'static,
{
let (handle, notified) = me.shared.owned.bind(future, me.clone(), id);
me.task_hooks.spawn(&TaskMeta {
#[cfg(tokio_unstable)]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | return;
};
let mut maybe_core = context.core.borrow_mut();
let core = if let Some(core) = maybe_core.as_mut() {
core
} else {
return;
};
let local = &mut core.tasks;
if self.shared.inject.is_closed() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | }
// reset woken to false and return original value
pub(crate) fn reset_woken(&self) -> bool {
self.shared.woken.swap(false, AcqRel)
}
pub(crate) fn num_alive_tasks(&self) -> usize {
self.shared.owned.num_alive_tasks()
}
pub(crate) fn injection_queue_depth(&self) -> usize {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | self.blocking_spawner.queue_depth()
}
cfg_64bit_metrics! {
pub(crate) fn spawned_tasks_count(&self) -> u64 {
self.shared.owned.spawned_tasks_count()
}
}
}
}
cfg_unstable! {
use std::num::NonZeroU64;
impl Handle {
pub(crate) fn owned_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | // 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/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | 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 signal shutdown
if let Some(core) = core.as_mut() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | 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.metrics.start_processing_scheduled_tasks();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | context.park_yield(core, handle)
} else {
context.park(core, handle)
};
core.metrics.start_processing_scheduled_tasks();
// Try polling the `block_on` future next
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | /// 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),
{
let context = self.context.expect_current_thread();
// Remove `core` from ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 794 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | return;
};
let mut maybe_core = context.core.borrow_mut();
let core = if let Some(core) = maybe_core.as_mut() {
core
} else {
return;
};
let local = &mut core.tasks;
if self.shared.inject.is_closed() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | }
// reset woken to false and return original value
pub(crate) fn reset_woken(&self) -> bool {
self.shared.woken.swap(false, AcqRel)
}
pub(crate) fn num_alive_tasks(&self) -> usize {
self.shared.owned.num_alive_tasks()
}
}
cfg_unstable_metrics! {
impl Handle {
pub(crat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.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, Inject};
use crate::runtime::task::{
self, JoinHandle, OwnedTasks, Schedule, Task, TaskHarnessScheduleHooks,
};
use crate::runti... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/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,
}
/// Data require... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:3 | 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,
/// Scheduler configuration options
config: Config,
/// Keeps track of various runtime met... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:4 | /// schedulers.
const DEFAULT_GLOBAL_QUEUE_INTERVAL: u32 = 31;
impl CurrentThread {
pub(crate) fn new(
driver: Driver,
driver_handle: driver::Handle,
blocking_spawner: blocking::Spawner,
seed_generator: RngSeedGenerator,
config: Config,
) -> (CurrentThread, Arc<Handle>) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:5 | driver: Some(driver),
metrics: MetricsBatch::new(&handle.shared.worker_metrics),
global_queue_interval,
unhandled_panic: false,
})));
let scheduler = CurrentThread {
core,
notify: Notify::new(),
};
(scheduler, handle)
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:6 | if let Ready(out) = future.as_mut().poll(cx) {
return Ready(Some(out));
}
Pending
}))
.expect("Failed to `Enter::block_on`")
{
return out;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:8 | }
assert!(handle.shared.owned.is_empty());
// Submit metrics
core.submit_metrics(handle);
// Shutdown the resource drivers
if let Some(driver) = core.driver.as_mut() {
driver.shutdown(&handle.driver);
}
core
}
impl fmt::Debug for CurrentThread {
fn fmt(&self, fmt: &mut fmt::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:9 | 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.len());
ret
}
fn push_task(&mut self, handle: &Handle, task: Notified) {
self.tas... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:10 | ret
}
/// 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.co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:11 | /// 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, || {
driv... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | future: F,
id: crate::runtime::task::Id,
) -> JoinHandle<F::Output>
where
F: crate::future::Future + Send + 'static,
F::Output: Send + 'static,
{
let (handle, notified) = me.shared.owned.bind(future, me.clone(), id);
me.task_hooks.spawn(&TaskMeta {
#[cfg(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | } else {
return;
};
let mut maybe_core = context.core.borrow_mut();
let core = if let Some(core) = maybe_core.as_mut() {
core
} else {
return;
};
let local = &mut core.tasks;
if self.shar... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | waker_ref(me)
}
// reset woken to false and return original value
pub(crate) fn reset_woken(&self) -> bool {
self.shared.woken.swap(false, AcqRel)
}
pub(crate) fn num_alive_tasks(&self) -> usize {
self.shared.owned.num_alive_tasks()
}
}
cfg_unstable_metrics! {
impl Handle ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | pub(crate) fn blocking_queue_depth(&self) -> usize {
self.blocking_spawner.queue_depth()
}
cfg_64bit_metrics! {
pub(crate) fn spawned_tasks_count(&self) -> u64 {
self.shared.owned.spawned_tasks_count()
}
}
}
}
cfg_unstable! {
use std:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | 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_task(self, task);
}
}
_ => {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | context::with_scheduler(|maybe_cx| match maybe_cx {
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 signal shutdown
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | #[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.metrics.start_processing... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | core = if !context.defer.is_empty() {
context.park_yield(core, handle)
} else {
context.park(core, handle)
};
core.metrics.start_processing_scheduled_tasks();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.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, Inject};
use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, Task};
use crate::runtime::{blocking, context, Config, M... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.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/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.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/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:4 | blocking_spawner: blocking::Spawner,
seed_generator: RngSeedGenerator,
config: Config,
) -> (CurrentThread, Arc<Handle>) {
let worker_metrics = WorkerMetrics::from_config(&config);
worker_metrics.set_thread_id(thread::current().id());
// Get the configured global queue inter... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:5 | (scheduler, handle)
}
#[track_caller]
pub(crate) fn block_on<F: Future>(&self, handle: &scheduler::Handle, future: F) -> F::Output {
pin!(future);
crate::runtime::context::enter_runtime(handle, false, |blocking| {
let handle = handle.as_current_thread();
// Attempt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:6 | }
}
})
}
fn take_core(&self, handle: &Arc<Handle>) -> Option<CoreGuard<'_>> {
let core = self.core.take()?;
Some(CoreGuard {
context: scheduler::Context::CurrentThread(Context {
handle: handle.clone(),
core: RefCell::new(Some(core... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:7 | // fail, but those will fail either way because the thread-local is
// not available anymore.
let context = core.context.expect_current_thread();
let core = context.core.borrow_mut().take().unwrap();
let core = shutdown2(core, handle);
*context.core.borrow_mu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:8 | 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 = self.tick.wrapping_add(1)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:9 | self.metrics.inc_local_schedule_count();
handle
.shared
.worker_metrics
.set_queue_depth(self.tasks.len());
}
fn submit_metrics(&mut self, handle: &Handle) {
self.metrics.submit(&handle.shared.worker_metrics, 0);
}
}
#[cfg(tokio_taskdump)]
fn wake_deferr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:10 | }
// 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 signaled
core.metrics.about_to_park();
core.submit_metrics(handle);
let (c, ()) = self.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:11 | 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.core.borrow_mut() = Some(core);
// E... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.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 {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | .map(|(id, trace)| dump::Task::new(id, trace))
.collect();
// 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.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | }
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
}
pub(crate) fn worker_local_queue_d... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | self.shared.owned.id
}
}
}
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>) -> Optio... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | /// 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`, even if the future panics.
struct CoreG... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | }
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();
let entry = core.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | // Yield to the driver, this drives the timer and pulls any
// pending I/O events.
core = context.park_yield(core, handle);
core.metrics.start_processing_scheduled_tasks();
}
});
match ret {
Some(ret) => ret,
None => {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 772 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | let context = self.context.expect_current_thread();
if let Some(core) = 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... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 772 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.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, Inject};
use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, Task};
use crate::runtime::{blocking, context, Config, M... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/src/runtime/scheduler/current_thread/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.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/mod.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/src/runtime/scheduler/current_thread/mod.rs | 81 | 140 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.