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:5 | driver: driver_handle,
blocking_spawner,
seed_generator,
local_tid,
});
let core = AtomicCell::new(Some(Box::new(Core {
tasks: VecDeque::with_capacity(INITIAL_CAPACITY),
tick: 0,
driver: Some(driver),
metrics: MetricsBa... | 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 | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:6 | } else {
let notified = self.notify.notified();
pin!(notified);
if let Some(out) = blocking
.block_on(poll_fn(|cx| {
if notified.as_mut().poll(cx).is_ready() {
return Ready(No... | 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 | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:7 | // 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,
None if std::thread::panicking() => return,
None => panic!("Oh no! We never placed the Core back, this is a bug!"),
... | 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 | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:8 | drop(task);
}
// Close the injection queue
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 re... | 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 | 281 | 340 |
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 | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/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 | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/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);
core = ... | 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 | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | //
// A drop-guard is employed at a higher level.
*self.core.borrow_mut() = Some(core);
// Execute the closure while tracking the execution budget
let ret = f();
// Take the scheduler core back
let core = self.core.borrow_mut().take().expect("core missing");
(co... | 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 | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | 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
///
/// This should only be used when this is a `LocalRuntime` or in another case where the run... | 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 | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | }
handle
}
/// Capture a snapshot of this runtime's state.
#[cfg(all(
tokio_unstable,
feature = "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 | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | .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 | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | assert_eq!(0, worker);
&self.shared.worker_metrics
}
}
cfg_unstable_metrics! {
impl Handle {
pub(crate) fn scheduler_metrics(&self) -> &SchedulerMetrics {
&self.shared.scheduler_metrics
}
pub(crate) fn worker_local_queue_depth(&self, worker: usize) -> usize {
... | 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 | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | }
}
impl fmt::Debug for Handle {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("current_thread::Handle { ... }").finish()
}
}
// ===== impl Shared =====
impl Schedule for Arc<Handle> {
fn release(&self, task: &Task<Self>) -> Option<Task<Self>> {
self.shared... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 09ad5367b8de39ae2532c7c0efe4136167be015d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09ad5367b8de39ae2532c7c0efe4136167be015d/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | fn hooks(&self) -> TaskHarnessScheduleHooks {
TaskHarnessScheduleHooks {
task_terminate_callback: self.task_hooks.task_terminate_callback.clone(),
}
}
cfg_unstable! {
fn unhandled_panic(&self) {
use crate::runtime::UnhandledPanic;
match self.shared.c... | 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 | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | fn wake(arc_self: Arc<Self>) {
Wake::wake_by_ref(&arc_self);
}
/// Wake by reference
fn wake_by_ref(arc_self: &Arc<Self>) {
let already_woken = arc_self.shared.woken.swap(true, Release);
if !already_woken {
use scheduler::Context::CurrentThread;
// If we ar... | 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 | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | core.metrics.start_processing_scheduled_tasks();
'outer: loop {
let handle = &context.handle;
if handle.reset_woken() {
let (c, res) = context.enter(core, || {
crate::task::coop::budget(|| future.as_mut().poll(&mut cx))
... | 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 | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:21 | // Try polling the `block_on` future next
continue 'outer;
}
};
let task = context.handle.shared.owned.assert_owner(task);
#[cfg(tokio_unstable)]
let task_meta = task.task_meta();
... | 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 | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:22 | }
}
/// 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... | 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 | 841 | 877 |
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 | 934f68d91c90777235e119f4b42f3de660c45bd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/934f68d91c90777235e119f4b42f3de660c45bd0/tokio/src/runtime/scheduler/current_thread/mod.rs | 1 | 60 |
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 | 934f68d91c90777235e119f4b42f3de660c45bd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/934f68d91c90777235e119f4b42f3de660c45bd0/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);
core = ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 934f68d91c90777235e119f4b42f3de660c45bd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/934f68d91c90777235e119f4b42f3de660c45bd0/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | fn hooks(&self) -> TaskHarnessScheduleHooks {
TaskHarnessScheduleHooks {
task_terminate_callback: self.task_hooks.task_terminate_callback.clone(),
}
}
cfg_unstable! {
fn unhandled_panic(&self) {
use crate::runtime::UnhandledPanic;
match self.shared.c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 934f68d91c90777235e119f4b42f3de660c45bd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/934f68d91c90777235e119f4b42f3de660c45bd0/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | 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.shared.woken.store(true, Release);
arc_self.driver.unpark();
}
}
// ===== CoreGuard =====
/// Used to ensure we always place the `Core` value ba... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 934f68d91c90777235e119f4b42f3de660c45bd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/934f68d91c90777235e119f4b42f3de660c45bd0/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | if let Ready(v) = res {
return (core, Some(v));
}
}
for _ in 0..handle.shared.config.event_interval {
// Make sure we didn't hit an unhandled_panic
if core.unhandled_panic {
retur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 934f68d91c90777235e119f4b42f3de660c45bd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/934f68d91c90777235e119f4b42f3de660c45bd0/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:21 | #[cfg(tokio_unstable)]
context.handle.task_hooks.poll_start_callback(&task_meta);
task.run();
#[cfg(tokio_unstable)]
context.handle.task_hooks.poll_stop_callback(&task_meta);
});
co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 934f68d91c90777235e119f4b42f3de660c45bd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/934f68d91c90777235e119f4b42f3de660c45bd0/tokio/src/runtime/scheduler/current_thread/mod.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:22 | 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, context));
*context.core.borrow_mut() = Some(core);
ret
}
}
impl Drop for CoreGuard<'_> {
fn drop(&... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 934f68d91c90777235e119f4b42f3de660c45bd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/934f68d91c90777235e119f4b42f3de660c45bd0/tokio/src/runtime/scheduler/current_thread/mod.rs | 841 | 865 |
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 | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/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);
core = ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | // 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)
}
pub(crate) fn defer(&self, waker: &Waker) {
self.defer.defer(waker);
}
}
// ====... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | handle
}
/// Spawn a task which isn't safe to send across thread boundaries onto the runtime.
///
/// # Safety
///
/// This should only be used when this is a `LocalRuntime` or in another case where the runtime
/// provably cannot be driven from or moved to different threads from the one on... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | /// Capture a snapshot of this runtime's state.
#[cfg(all(
tokio_unstable,
feature = "taskdump",
target_os = "linux",
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
))]
pub(crate) fn dump(&self) -> crate::runtime::Dump {
use crate::runtime::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | drop(maybe_core);
// Taking a taskdump could wakes every task, but we probably don't want
// the `yield_now` vector to be that large under normal circumstances.
// Therefore, we free its allocation.
wake_deferred_tasks_and_free(context);
});
dump::Dump::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | cfg_unstable_metrics! {
impl Handle {
pub(crate) fn scheduler_metrics(&self) -> &SchedulerMetrics {
&self.shared.scheduler_metrics
}
pub(crate) fn worker_local_queue_depth(&self, worker: usize) -> usize {
self.worker_metrics(worker).queue_depth()
}
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("current_thread::Handle { ... }").finish()
}
}
// ===== impl Shared =====
impl Schedule for Arc<Handle> {
fn release(&self, task: &Task<Self>) -> Option<Task<Self>> {
self.shared.owned.remove(task)
}
fn sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | }
cfg_unstable! {
fn unhandled_panic(&self) {
use crate::runtime::UnhandledPanic;
match self.shared.config.unhandled_panic {
UnhandledPanic::Ignore => {
// Do nothing
}
UnhandledPanic::ShutdownRuntime => {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | /// 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 | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | }
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 | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:21 | #[cfg(tokio_unstable)]
context.handle.task_hooks.poll_stop_callback(&task_meta);
});
core = c;
}
core.metrics.end_processing_scheduled_tasks();
// Yield to the driver, this drives the timer and pulls any
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:22 | *context.core.borrow_mut() = Some(core);
ret
}
}
impl Drop for CoreGuard<'_> {
fn drop(&mut self) {
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
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d2799d791b10388e60a2a5fe5e4a33b3336e1465 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2799d791b10388e60a2a5fe5e4a33b3336e1465/tokio/src/runtime/scheduler/current_thread/mod.rs | 841 | 861 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | handle
}
/// Spawn a task which isn't safe to send across thread boundaries onto the runtime.
///
/// # Safety
///
/// This should only be used when this is a `LocalRuntime` or in another case where the runtime
/// provably cannot be driven from or moved to different threads from the one on... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | cfg_unstable_metrics! {
impl Handle {
pub(crate) fn scheduler_metrics(&self) -> &SchedulerMetrics {
&self.shared.scheduler_metrics
}
pub(crate) fn worker_local_queue_depth(&self, worker: usize) -> usize {
self.worker_metrics(worker).queue_depth()
}
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | impl fmt::Debug for Handle {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("current_thread::Handle { ... }").finish()
}
}
// ===== impl Shared =====
impl Schedule for Arc<Handle> {
fn release(&self, task: &Task<Self>) -> Option<Task<Self>> {
self.shared.owne... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | task_terminate_callback: self.task_hooks.task_terminate_callback.clone(),
}
}
cfg_unstable! {
fn unhandled_panic(&self) {
use crate::runtime::UnhandledPanic;
match self.shared.config.unhandled_panic {
UnhandledPanic::Ignore => {
// Do... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | }
/// 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.
struc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | return (core, Some(v));
}
}
for _ in 0..handle.shared.config.event_interval {
// Make sure we didn't hit an unhandled_panic
if core.unhandled_panic {
return (core, None);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:21 | task.run();
#[cfg(tokio_unstable)]
context.handle.task_hooks.poll_stop_callback(&task_meta);
});
core = c;
}
core.metrics.end_processing_scheduled_tasks();
// Yield to the driver, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/src/runtime/scheduler/current_thread/mod.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:22 | // Call the closure and place `core` back
let (core, ret) = context::set_scheduler(&self.context, || f(core, context));
*context.core.borrow_mut() = Some(core);
ret
}
}
impl Drop for CoreGuard<'_> {
fn drop(&mut self) {
let context = self.context.expect_current_thread();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/src/runtime/scheduler/current_thread/mod.rs | 841 | 863 |
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 | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/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 | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | }
}
// ===== impl Handle =====
impl Handle {
/// Spawns a future onto the `CurrentThread` scheduler
#[track_caller]
pub(crate) fn spawn<F>(
me: &Arc<Self>,
future: F,
id: crate::runtime::task::Id,
spawned_at: SpawnLocation,
) -> JoinHandle<F::Output>
where
F... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | #[track_caller]
pub(crate) unsafe fn spawn_local<F>(
me: &Arc<Self>,
future: F,
id: crate::runtime::task::Id,
spawned_at: SpawnLocation,
) -> JoinHandle<F::Output>
where
F: crate::future::Future + 'static,
F::Output: 'static,
{
// Safety: the calle... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | use task::trace::trace_current_thread;
let mut traces = vec![];
// todo: how to make this work outside of a runtime context?
context::with_scheduler(|maybe_context| {
// drain the local queue
let context = if let Some(context) = maybe_context {
context.e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | fn next_remote_task(&self) -> Option<Notified> {
self.shared.inject.pop()
}
fn waker_ref(me: &Arc<Self>) -> WakerRef<'_> {
// Set woken to true when enter block_on, ensure outer future
// be polled for the first time when enter loop
me.shared.woken.store(true, Release);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/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 num_blocking_threads(&self) -> usize {
self.blocking_spawner.num_threads()
}
pub(crate) fn num_idle_blocking_threads(&self) -> usize {
self.blocking_spawner.num_idle_threads()
}
pub(crate) fn blocking_queue_depth(&self) -> usize {
self.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | fn release(&self, task: &Task<Self>) -> Option<Task<Self>> {
self.shared.owned.remove(task)
}
fn schedule(&self, task: task::Notified<Self>) {
use scheduler::Context::CurrentThread;
context::with_scheduler(|maybe_cx| match maybe_cx {
Some(CurrentThread(cx)) if Arc::ptr_eq(s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | // Do nothing
}
UnhandledPanic::ShutdownRuntime => {
use scheduler::Context::CurrentThread;
// This hook is only called from within the runtime, so
// `context::with_scheduler` should match with `&self`, i.e.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | /// Used to ensure we always place the `Core` value back into its slot in
/// `CurrentThread`, even if the future panics.
struct CoreGuard<'a> {
context: scheduler::Context,
scheduler: &'a CurrentThread,
}
impl CoreGuard<'_> {
#[track_caller]
fn block_on<F: Future>(self, future: F) -> F::Output {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | core.tick();
let entry = core.next_task(handle);
let task = match entry {
Some(entry) => entry,
None => {
core.metrics.end_processing_scheduled_tasks();
core = if !context.d... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/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();
// 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();
}
});
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 801 | 853 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:22 | fn drop(&mut self) {
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);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/scheduler/current_thread/mod.rs | 841 | 853 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | }
}
// ===== impl Handle =====
impl Handle {
/// Spawns a future onto the `CurrentThread` scheduler
#[track_caller]
pub(crate) fn spawn<F>(
me: &Arc<Self>,
future: F,
id: crate::runtime::task::Id,
spawned_at: SpawnLocation,
) -> JoinHandle<F::Output>
where
F... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | pub(crate) unsafe fn spawn_local<F>(
me: &Arc<Self>,
future: F,
id: crate::runtime::task::Id,
spawned_at: SpawnLocation,
) -> JoinHandle<F::Output>
where
F: crate::future::Future + 'static,
F::Output: 'static,
{
let (handle, notified) = me
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | // todo: how to make this work outside of a runtime context?
context::with_scheduler(|maybe_context| {
// drain the local queue
let context = if let Some(context) = maybe_context {
context.expect_current_thread()
} else {
return;
};... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | }
fn waker_ref(me: &Arc<Self>) -> WakerRef<'_> {
// Set woken to true when enter block_on, ensure outer future
// be polled for the first time when enter loop
me.shared.woken.store(true, Release);
waker_ref(me)
}
// reset woken to false and return original value
pub(cra... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/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 num_idle_blocking_threads(&self) -> usize {
self.blocking_spawner.num_idle_threads()
}
pub(crate) fn blocking_queue_depth(&self) -> usize {
self.blocking_spawner.queue_depth()
}
cfg_64bit_metrics! {
pub(crate) fn spawned_task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | fn schedule(&self, task: task::Notified<Self>) {
use scheduler::Context::CurrentThread;
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 r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | use scheduler::Context::CurrentThread;
// This hook is only called from within the runtime, so
// `context::with_scheduler` should match with `&self`, i.e.
// there is no opportunity for a nested scheduler to be
// called.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | struct CoreGuard<'a> {
context: scheduler::Context,
scheduler: &'a CurrentThread,
}
impl CoreGuard<'_> {
#[track_caller]
fn block_on<F: Future>(self, future: F) -> F::Output {
let ret = self.enter(|mut core, context| {
let waker = Handle::waker_ref(&context.handle);
let ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | let task = match entry {
Some(entry) => entry,
None => {
core.metrics.end_processing_scheduled_tasks();
core = if !context.defer.is_empty() {
context.park_yield(core, handle)
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:21 | // pending I/O events.
core = context.park_yield(core, handle);
core.metrics.start_processing_scheduled_tasks();
}
});
match ret {
Some(ret) => ret,
None => {
// `block_on` panicked.
panic!("a spawned t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 801 | 850 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:22 | 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 threads that could steal the driver.
self.schedu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/scheduler/current_thread/mod.rs | 841 | 850 |
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 | a0d5b8ab308bbeaa8090d411550d6c887d699096 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/runtime/scheduler/current_thread/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | pub(crate) unsafe fn spawn_local<F>(
me: &Arc<Self>,
future: F,
id: crate::runtime::task::Id,
spawned_at: SpawnLocation,
) -> JoinHandle<F::Output>
where
F: crate::future::Future + 'static,
F::Output: 'static,
{
let (handle, notified) = me
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | a0d5b8ab308bbeaa8090d411550d6c887d699096 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
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 | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:2 | /// 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
pub(crate) task_hooks... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/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 | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:4 | 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 new(
driver: Driver... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:5 | },
driver: driver_handle,
blocking_spawner,
seed_generator,
local_tid,
});
let core = AtomicCell::new(Some(Box::new(Core {
tasks: VecDeque::with_capacity(INITIAL_CAPACITY),
tick: 0,
driver: Some(driver),
met... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:6 | return core.block_on(future);
} else {
let notified = self.notify.notified();
pin!(notified);
if let Some(out) = blocking
.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/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:7 | 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,
None if std::thread::panicking() => return,
None => panic!("Oh no! W... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:8 | while let Some(task) = core.next_local_task(handle) {
drop(task);
}
// Close the injection queue
handle.shared.inject.close();
// Drain remote queue
while let Some(task) = handle.shared.inject.pop() {
drop(task);
}
assert!(handle.shared.owned.is_empty());
// Submit me... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:9 | if self.tick % self.global_queue_interval == 0 {
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 ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 321 | 380 |
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 | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | self.defer.defer(waker);
}
}
// ===== impl Handle =====
impl Handle {
/// Spawns a future onto the `CurrentThread` scheduler
#[track_caller]
pub(crate) fn spawn<F>(
me: &Arc<Self>,
future: F,
id: crate::runtime::task::Id,
) -> JoinHandle<F::Output>
where
F: crat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | /// This should only be used when this is a `LocalRuntime` or in another case where the runtime
/// provably cannot be driven from or moved to different threads from the one on which the task
/// is spawned.
#[track_caller]
pub(crate) unsafe fn spawn_local<F>(
me: &Arc<Self>,
future: F,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:14 | use crate::runtime::dump;
use task::trace::trace_current_thread;
let mut traces = vec![];
// todo: how to make this work outside of a runtime context?
context::with_scheduler(|maybe_context| {
// drain the local queue
let context = if let Some(context) = maybe_c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:15 | }
fn next_remote_task(&self) -> Option<Notified> {
self.shared.inject.pop()
}
fn waker_ref(me: &Arc<Self>) -> WakerRef<'_> {
// Set woken to true when enter block_on, ensure outer future
// be polled for the first time when enter loop
me.shared.woken.store(true, Release);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/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 num_blocking_threads(&self) -> usize {
self.blocking_spawner.num_threads()
}
pub(crate) fn num_idle_blocking_threads(&self) -> usize {
self.blocking_spawner.num_idle_threads()
}
pub(crate) fn blocking_queue_depth(&self) -> usize {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:17 | impl Schedule for Arc<Handle> {
fn release(&self, task: &Task<Self>) -> Option<Task<Self>> {
self.shared.owned.remove(task)
}
fn schedule(&self, task: task::Notified<Self>) {
use scheduler::Context::CurrentThread;
context::with_scheduler(|maybe_cx| match maybe_cx {
Some... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:18 | UnhandledPanic::Ignore => {
// Do nothing
}
UnhandledPanic::ShutdownRuntime => {
use scheduler::Context::CurrentThread;
// This hook is only called from within the runtime, so
// `context::with_scheduler` sh... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:19 | // ===== CoreGuard =====
/// Used to ensure we always place the `Core` value back into its slot in
/// `CurrentThread`, even if the future panics.
struct CoreGuard<'a> {
context: scheduler::Context,
scheduler: &'a CurrentThread,
}
impl CoreGuard<'_> {
#[track_caller]
fn block_on<F: Future>(self, futur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:20 | core.tick();
let entry = core.next_task(handle);
let task = match entry {
Some(entry) => entry,
None => {
core.metrics.end_processing_scheduled_tasks();
core = if !context.d... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:22 | impl Drop for CoreGuard<'_> {
fn drop(&mut self) {
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.s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/current_thread/mod.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/scheduler/current_thread/mod.rs | 841 | 854 |
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 | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/src/runtime/scheduler/current_thread/mod.rs | 1 | 60 |
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 | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/src/runtime/scheduler/current_thread/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:12 | }
}
// ===== impl Handle =====
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::Ou... | 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 | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:13 | ) -> JoinHandle<F::Output>
where
F: crate::future::Future + 'static,
F::Output: 'static,
{
let (handle, notified) = me.shared.owned.bind_local(future, me.clone(), id);
me.task_hooks.spawn(&TaskMeta {
id,
_phantom: Default::default(),
});
... | 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 | 481 | 540 |
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 | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/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 | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/src/runtime/scheduler/current_thread/mod.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/current_thread/mod.rs:16 | 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.shared.owned... | 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 | 601 | 660 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.