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/multi_thread/worker.rs:9 | inject,
idle,
owned: OwnedTasks::new(size),
synced: Mutex::new(Synced {
idle: idle_synced,
inject: inject_synced,
#[cfg(all(tokio_unstable, feature = "time"))]
inject_timers: Vec::new(),
}),
shutd... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:10 | F: FnOnce() -> R,
{
// Try to steal the worker core back
struct Reset {
take_core: bool,
budget: coop::Budget,
}
impl Drop for Reset {
fn drop(&mut self) {
with_current(|maybe_cx| {
if let Some(cx) = maybe_cx {
if self.take_core {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:11 | ) {
(context::EnterRuntime::Entered { .. }, true) => {
// We are on a thread pool runtime thread, so we just need to
// set up blocking.
had_entered = true;
}
(
context::EnterRuntime::Entered {
allow_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:12 | // Since deferred tasks don't stay on `core`, make sure to wake them
// before blocking.
cx.defer.wake();
// Get the worker core. If none is set, then blocking is fine!
let mut core = match cx.core.borrow_mut().take() {
Some(core) => core,
None => return Ok(()),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:13 | if let Err(panic_message) = setup_result {
panic!("{}", panic_message);
}
if had_entered {
// Unset the current task's budget. Blocking sections are not
// constrained by task budgets.
let _reset = Reset {
take_core,
budget: coop::stop(),
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:14 | // Catching panics on worker threads in tests is quite tricky. Instead, when
// debug assertions are enabled, we just abort the process.
#[cfg(debug_assertions)]
let _abort_on_panic = AbortOnPanic;
// Acquire a core. If this fails, then another thread is running this
// worker and there is nothing ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:15 | fn run(&self, mut core: Box<Core>) -> RunResult {
// Reset `lifo_enabled` here in case the core was previously stolen from
// a task that had the LIFO slot disabled.
self.reset_lifo_enabled(&mut core);
// Start as "processing" tasks as polling tasks from the local queue
// will ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:16 | self.park_yield(core)
} else {
self.park(core)
};
core.stats.start_processing_scheduled_tasks();
}
}
#[cfg(all(tokio_unstable, feature = "time"))]
{
match self.worker.handle.timer_flavor {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:17 | // enabled, and this worker had the driver, wake a parked worker to come
// grab it from us.
//
// Note that this is only done when we are *actually* about to poll a
// task, rather than whenever the worker has unparked. When the worker
// has been unparked, it may not actually h... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:18 | .task_hooks
.poll_start_callback(&task_meta);
task.run();
#[cfg(tokio_unstable)]
self.worker.handle.task_hooks.poll_stop_callback(&task_meta);
let mut lifo_polls = 0;
// As long as there is budget remaining and a task exists in the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:19 | core.run_queue.push_back_or_overflow(
task,
&*self.worker.handle,
&mut core.stats,
);
// If we hit this point, the LIFO slot should be enabled.
// There is no need to reset it.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:20 | task.run();
#[cfg(tokio_unstable)]
self.worker.handle.task_hooks.poll_stop_callback(&task_meta);
}
})
}
fn reset_lifo_enabled(&self, core: &mut Core) {
core.lifo_enabled = !self.worker.handle.shared.config.disable_lifo_slot;
}
fn assert_lifo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:21 | /// This function checks if indeed there's no more work left to be done before parking.
/// Also important to notice that, before parking, the worker thread will try to take
/// ownership of the Driver (IO/Time) and dispatch any events that might have fired.
/// Whenever a worker thread executes the Driver ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:22 | self.park_internal(core, Some(Duration::from_millis(0)))
}
fn park_internal(&self, mut core: Box<Core>, duration: Option<Duration>) -> Box<Core> {
self.assert_lifo_enabled_is_correct(&core);
// Take the parker out of core
let mut park = core.park.take().expect("park missing");
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:23 | // suppress unused variable warning
let _ = auto_advance_duration;
}
#[cfg(tokio_unstable)]
TimerFlavor::Alternative => {
// Must happens before placing back the parker, as the `Handle::schedule_local`
// will delay the notify if the pa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:24 | /// * Register remote timers to the local timer wheel.
/// * Adjust the park duration based on
/// * the next timer expiration time.
/// * whether auto-advancing is required (feature = "test-util").
///
/// # Returns
///
/// `(Box<Core>, park_duration, auto_advance_duration)`
fn main... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:25 | let should_yield = !wake_queue.is_empty();
let next_timer = util::time_alt::next_expiration_time(&time_cx.wheel, &handle.driver);
(should_yield, next_timer)
});
wake_queue.wake_all();
if should_yield {
MaintainLocalTimer {
park_duration: So... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:26 | with_current(|maybe_cx| {
let cx = maybe_cx.expect("function should be called when core is present");
assert_eq!(
Arc::as_ptr(&cx.worker.handle),
Arc::as_ptr(&self.worker.handle),
"function should be called on the exact same worker"
);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:27 | Some(core) if core.is_shutdown => f(Some(time_alt::TempLocalContext::new_shutdown())),
Some(core) => f(Some(time_alt::TempLocalContext::new_running(
&mut core.time_context,
))),
None => f(None),
})
}
#[cfg(tokio_unstable)]
pub(crate) fn worker_ind... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:28 | let cap = usize::min(
// Other threads can only **remove** tasks from the current
// worker's `run_queue`. So, we can be confident that by the
// time we call `run_queue.push_back` below, there will be *at
// least* `cap` available slots in the queue.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:29 | // Pop the first task to return immediately
let ret = tasks.next();
// Push the rest of the on the run queue
self.run_queue.push_back(tasks);
ret
}
}
fn next_local_task(&mut self) -> Option<Notified> {
self.lifo_slot.take().or_else(|| self.run_q... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:30 | .steal_into(&mut self.run_queue, &mut self.stats)
{
return Some(task);
}
}
// Fallback on checking the global queue
worker.handle.next_remote_task()
}
fn transition_to_searching(&mut self, worker: &Worker) -> bool {
if !self.is_searching ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:31 | /// Prepares the worker state for parking.
///
/// Returns true if the transition happened, false if there is work to do first.
fn transition_to_parked(&mut self, worker: &Worker) -> bool {
// Workers should not park if they have work to do
if self.has_tasks() || self.is_traced {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:32 | .shared
.idle
.unpark_worker_by_id(&worker.handle.shared, worker.index);
return true;
}
if worker
.handle
.shared
.idle
.is_parked(&worker.handle.shared, worker.index)
{
return false;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:33 | // Start from a random inner list
let start = self
.rand
.fastrand_n(worker.handle.shared.owned.get_shard_size() as u32);
// Signal to all tasks to shut down.
worker
.handle
.shared
.owned
.close_and_shutdown_all(start as us... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:34 | fn inject(&self) -> &inject::Shared<Arc<Handle>> {
&self.handle.shared.inject
}
}
impl Handle {
pub(super) fn schedule_task(&self, task: Notified, is_yield: bool) {
with_current(|maybe_cx| {
if let Some(cx) = maybe_cx {
// Make sure the task is part of the **current*... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:35 | core.run_queue
.push_back_or_overflow(task, self, &mut core.stats);
true
} else {
// Push to the LIFO slot
let prev = core.lifo_slot.take();
let ret = prev.is_some();
if let Some(prev) = prev {
core.run_queue
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:36 | // safety: passing in correct `idle::Synced`
unsafe {
self.shared.inject.push(&mut synced.inject, task);
}
}
#[cfg(all(tokio_unstable, feature = "time"))]
pub(crate) fn push_remote_timer(&self, hdl: time_alt::EntryHandle) {
assert_eq!(self.timer_flavor, TimerFlavor::Alte... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:37 | fn notify_parked_local(&self) -> bool {
super::counters::inc_num_inc_notify_local();
if let Some(index) = self.shared.idle.worker_to_notify(&self.shared) {
super::counters::inc_num_unparks_local();
self.shared.remotes[index].unpark.unpark(&self.driver);
true
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:38 | // We are the final searching worker. Because work was found, we
// need to notify another worker.
self.notify_parked_local()
} else {
false
}
}
/// Signals that a worker has observed the shutdown signal and has replaced
/// its core back into its handle.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:39 | fn push(&self, task: task::Notified<Arc<Handle>>) {
self.push_remote_task(task);
}
fn push_batch<I>(&self, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
self.shared.inject.push_batch(self, iter);
}
}
}
pub(crate) struct Injec... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,521 | 1,570 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:40 | #[track_caller]
fn with_current<R>(f: impl FnOnce(Option<&Context>) -> R) -> R {
use scheduler::Context::MultiThread;
context::with_scheduler(|ctx| match ctx {
Some(MultiThread(ctx)) => f(Some(ctx)),
_ => f(None),
})
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,561 | 1,570 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:2 | //! inject queue.
//!
//! The first case can only happen if the `OwnedTasks::bind` call happens before
//! or during step 1 of shutdown. In this case, the runtime will clean up the
//! task in step 3 of shutdown.
//!
//! In the latter case, the task was not spawned and the task is immediately
//! cancelled by the sp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:4 | /// When `true`, locally scheduled tasks go to the LIFO slot. When `false`,
/// they go to the back of the `run_queue`.
lifo_enabled: bool,
/// The worker-local run queue.
run_queue: queue::Local<Arc<Handle>>,
#[cfg(all(tokio_unstable, feature = "time"))]
time_context: time_alt::LocalContext,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:5 | /// how they communicate between each other.
remotes: Box<[Remote]>,
/// Global task queue used for:
/// 1. Submit work to the scheduler while **not** currently on a worker thread.
/// 2. Submit work to the scheduler when a worker run queue is saturated
pub(super) inject: inject::Shared<Arc<Handl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:6 | }
/// Data synchronized by the scheduler mutex
pub(crate) struct Synced {
/// Synchronized state for `Idle`.
pub(super) idle: idle::Synced,
/// Synchronized state for `Inject`.
pub(crate) inject: inject::Synced,
#[cfg(all(tokio_unstable, feature = "time"))]
/// Timers pending to be registered... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:7 | pub(crate) struct Launch(Vec<Arc<Worker>>);
/// Running a task may consume the core. If the core is still available when
/// running the task completes, it is returned. Otherwise, the worker will need
/// to stop processing.
type RunResult = Result<Box<Core>, ()>;
/// A notified task handle
type Notified = task::Noti... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:8 | cores.push(Box::new(Core {
tick: 0,
lifo_slot: None,
lifo_enabled: !config.disable_lifo_slot,
run_queue,
#[cfg(all(tokio_unstable, feature = "time"))]
time_context: time_alt::LocalContext::new(),
is_searching: false,
is_shut... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:9 | config,
scheduler_metrics: SchedulerMetrics::new(),
worker_metrics: worker_metrics.into_boxed_slice(),
_counters: Counters,
},
driver: driver_handle,
blocking_spawner,
seed_generator,
timer_flavor,
#[cfg(all(tokio_unstable, feature = "t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:10 | if let Some(cx) = maybe_cx {
if self.take_core {
let core = cx.worker.core.take();
if core.is_some() {
cx.worker.handle.shared.worker_metrics[cx.worker.index]
.set_thread_id(thread::current()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:11 | ) => {
// We are on an executor, but _not_ on the thread pool. That is
// _only_ okay if we are in a thread pool runtime's block_on
// method:
if allow_block_in_place {
had_entered = true;
return Ok(());
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:12 | // run this core. Except for the task in the lifo_slot, all tasks can be
// stolen, so we move the task out of the lifo_slot to the run_queue.
if let Some(task) = core.lifo_slot.take() {
core.run_queue
.push_back_or_overflow(task, &*cx.worker.handle, &mut core.stats);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:13 | };
crate::runtime::context::exit_runtime(f)
} else {
f()
}
}
impl Launch {
pub(crate) fn launch(mut self) {
for worker in self.0.drain(..) {
runtime::spawn_blocking(move || run(worker));
}
}
}
fn run(worker: Arc<Worker>) {
#[allow(dead_code)]
struct... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:14 | worker.handle.shared.worker_metrics[worker.index].set_thread_id(thread::current().id());
let handle = scheduler::Handle::MultiThread(worker.handle.clone());
crate::runtime::context::enter_runtime(&handle, true, |_| {
// Set the worker context.
let cx = scheduler::Context::MultiThread(Context {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:15 | if core.is_traced {
core = self.worker.handle.trace_core(core);
}
// Increment the tick
core.tick();
// Run maintenance, if needed
core = self.maintenance(core);
// First, check work available to the current worker.
i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:16 | TimerFlavor::Traditional => {}
TimerFlavor::Alternative => {
util::time_alt::shutdown_local_timers(
&mut core.time_context.wheel,
&mut core.time_context.canc_rx,
self.worker.handle.take_remote_timers(),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:17 | coop::budget(|| {
// Unlike the poll time above, poll start callback is attached to the task id,
// so it is tightly associated with the actual poll invocation.
#[cfg(tokio_unstable)]
self.worker
.handle
.task_hooks
.poll_st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:18 | if !coop::has_budget_remaining() {
core.stats.end_poll();
// Not enough budget left to run the LIFO task, push it to
// the back of the queue and return.
core.run_queue.push_back_or_overflow(
task,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:19 | #[cfg(tokio_unstable)]
self.worker
.handle
.task_hooks
.poll_start_callback(&task_meta);
task.run();
#[cfg(tokio_unstable)]
self.worker.handle.task_hooks.poll_stop_callback(&task_meta);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:20 | core
}
/// Parks the worker thread while waiting for tasks to execute.
///
/// This function checks if indeed there's no more work left to be done before parking.
/// Also important to notice that, before parking, the worker thread will try to take
/// ownership of the Driver (IO/Time) and disp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:21 | f();
}
core
}
fn park_yield(&self, core: Box<Core>) -> Box<Core> {
self.park_internal(core, Some(Duration::from_millis(0)))
}
fn park_internal(&self, mut core: Box<Core>, duration: Option<Duration>) -> Box<Core> {
self.assert_lifo_enabled_is_correct(&core);
// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:22 | self.defer.wake();
#[cfg(feature = "time")]
match self.worker.handle.timer_flavor {
TimerFlavor::Traditional => {
// suppress unused variable warning
let _ = auto_advance_duration;
}
#[cfg(tokio_unstable)]
TimerFlavor::Alte... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:23 | #[cfg(all(tokio_unstable, feature = "time"))]
/// Maintain local timers before parking the resource driver.
///
/// * Remove cancelled timers from the local timer wheel.
/// * Register remote timers to the local timer wheel.
/// * Adjust the park duration based on
/// * the next timer expirati... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:24 | handle.take_remote_timers(),
&mut wake_queue,
);
util::time_alt::remove_cancelled_timers(&mut time_cx.wheel, &mut time_cx.canc_rx);
let should_yield = !wake_queue.is_empty();
let next_timer = util::time_alt::next_expiration_time(&time_cx.wheel, &handle.dr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:25 | fn maintain_local_timers_after_parking(&self, auto_advance_duration: Option<Duration>) {
let handle = &self.worker.handle;
let mut wake_queue = time_alt::WakeQueue::new();
with_current(|maybe_cx| {
let cx = maybe_cx.expect("function should be called when core is present");
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:26 | where
F: FnOnce(Option<time_alt::TempLocalContext<'_>>) -> R,
{
self.with_core(|maybe_core| match maybe_core {
Some(core) if core.is_shutdown => f(Some(time_alt::TempLocalContext::new_shutdown())),
Some(core) => f(Some(time_alt::TempLocalContext::new_running(
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:27 | if worker.inject().is_empty() {
return None;
}
// Other threads can only **remove** tasks from the current worker's
// `run_queue`. So, we can be confident that by the time we call
// `run_queue.push_back` below, there will be *at least* `cap`
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:28 | fn next_local_task(&mut self) -> Option<Notified> {
self.lifo_slot.take().or_else(|| self.run_queue.pop())
}
/// Function responsible for stealing tasks from another worker
///
/// Note: Only if less than half the workers are searching for tasks to steal
/// a new worker will actually try t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:29 | if !self.is_searching {
self.is_searching = worker.handle.shared.idle.transition_worker_to_searching();
}
self.is_searching
}
fn transition_from_searching(&mut self, worker: &Worker) {
if !self.is_searching {
return;
}
self.is_searching = false;... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:30 | // between the last work scan and transitioning out of searching.
let is_last_searcher = worker.handle.shared.idle.transition_worker_to_parked(
&worker.handle.shared,
worker.index,
self.is_searching,
);
// The worker is no longer searching. Setting this is th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:31 | {
return false;
}
// When unparked, the worker is in the searching state.
self.is_searching = true;
true
}
/// Runs maintenance work such as checking the pool's state.
fn maintenance(&mut self, worker: &Worker) {
self.stats
.submit(&worker.ha... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:32 | self.stats
.submit(&worker.handle.shared.worker_metrics[worker.index]);
}
/// Shuts down the core.
fn shutdown(&mut self, handle: &Handle) {
// Take the core
let mut park = self.park.take().expect("park missing");
// Drain the queue
while self.next_local_task().... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:33 | // And the current thread still holds a core
if let Some(core) = cx.core.borrow_mut().as_mut() {
self.schedule_local(core, task, is_yield);
return;
}
}
}
// Otherwise, use the inject queue.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:34 | }
core.lifo_slot = Some(task);
ret
};
// Only notify if not currently parked. If `park` is `None`, then the
// scheduling is from a resource driver. As notifications often come in
// batches, the notification is delayed until the park is complete.
if sh... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:35 | synced.inject_timers.push(hdl);
}
self.notify_parked_remote();
}
#[cfg(all(tokio_unstable, feature = "time"))]
pub(crate) fn take_remote_timers(&self) -> Vec<time_alt::EntryHandle> {
assert_eq!(self.timer_flavor, TimerFlavor::Alternative);
// It's ok to lost the race, as ano... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:36 | pub(super) fn notify_all(&self) {
for remote in &self.shared.remotes[..] {
remote.unpark.unpark(&self.driver);
}
}
fn notify_if_work_pending(&self) {
for remote in &self.shared.remotes[..] {
if !remote.steal.is_empty() {
self.notify_parked_local()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:37 | debug_assert!(self.shared.owned.is_empty());
for mut core in cores.drain(..) {
core.shutdown(self);
}
// Drain the injection queue
//
// We already shut down every task, so we can simply drop the tasks.
while let Some(task) = self.next_remote_task() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:38 | &mut self.lock.inject
}
}
impl<'a> Lock<inject::Synced> for &'a Handle {
type Handle = InjectGuard<'a>;
fn lock(self) -> Self::Handle {
InjectGuard {
lock: self.shared.synced.lock(),
}
}
}
#[cfg(all(tokio_unstable, feature = "time"))]
/// Returned by [`Context::maintain_lo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 967f5715a71d5d2600b71da8c4ab652c4e644a41 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,481 | 1,510 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:3 | cfg_taskdump! {
mod taskdump;
}
cfg_not_taskdump! {
mod taskdump_mock;
}
#[cfg(all(tokio_unstable, feature = "time"))]
use crate::loom::sync::atomic::AtomicBool;
#[cfg(all(tokio_unstable, feature = "time"))]
use crate::runtime::time_alt;
#[cfg(all(tokio_unstable, feature = "time"))]
use crate::runtime::sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:4 | #[cfg(all(tokio_unstable, feature = "time"))]
time_context: time_alt::LocalContext,
/// True if the worker is currently searching for more work. Searching
/// involves attempting to steal from other workers.
is_searching: bool,
/// True if the scheduler is being shutdown
is_shutdown: bool,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:5 | pub(crate) struct Shared {
/// Per-worker remote state. All other workers have access to this and is
/// how they communicate between each other.
remotes: Box<[Remote]>,
/// Global task queue used for:
/// 1. Submit work to the scheduler while **not** currently on a worker thread.
/// 2. Subm... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:6 | /// the `tokio_internal_mt_counters` `cfg` flag is set.
_counters: Counters,
}
/// Data synchronized by the scheduler mutex
pub(crate) struct Synced {
/// Synchronized state for `Idle`.
pub(super) idle: idle::Synced,
/// Synchronized state for `Inject`.
pub(crate) inject: inject::Synced,
#[cf... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:7 | /// Starts the workers
pub(crate) struct Launch(Vec<Arc<Worker>>);
/// Running a task may consume the core. If the core is still available when
/// running the task completes, it is returned. Otherwise, the worker will need
/// to stop processing.
type RunResult = Result<Box<Core>, ()>;
/// A notified task handle
typ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:8 | let stats = Stats::new(&metrics);
cores.push(Box::new(Core {
tick: 0,
lifo_enabled: !config.disable_lifo_slot,
run_queue,
#[cfg(all(tokio_unstable, feature = "time"))]
time_context: time_alt::LocalContext::new(),
is_searching: false,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:9 | }),
shutdown_cores: Mutex::new(vec![]),
trace_status: TraceStatus::new(remotes_len),
config,
scheduler_metrics: SchedulerMetrics::new(),
worker_metrics: worker_metrics.into_boxed_slice(),
_counters: Counters,
},
driver: driver_handl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:10 | impl Drop for Reset {
fn drop(&mut self) {
with_current(|maybe_cx| {
if let Some(cx) = maybe_cx {
if self.take_core {
let core = cx.worker.core.take();
if core.is_some() {
cx.worker.handl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:11 | allow_block_in_place,
},
false,
) => {
// We are on an executor, but _not_ on the thread pool. That is
// _only_ okay if we are in a thread pool runtime's block_on
// method:
if allow_block_in_place {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:12 | };
// If we heavily call `spawn_blocking`, there might be no available thread to
// run this core. Except for the task in the lifo_slot, all tasks can be
// stolen, so we move the task out of the lifo_slot to the run_queue.
if let Some(task) = core.run_queue.pop_lifo() {
cor... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:13 | let _reset = Reset {
take_core,
budget: coop::stop(),
};
crate::runtime::context::exit_runtime(f)
} else {
f()
}
}
impl Launch {
pub(crate) fn launch(mut self) {
for worker in self.0.drain(..) {
runtime::spawn_blocking(move || run(worker)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:14 | Some(core) => core,
None => return,
};
worker.handle.shared.worker_metrics[worker.index].set_thread_id(thread::current().id());
let handle = scheduler::Handle::MultiThread(worker.handle.clone());
crate::runtime::context::enter_runtime(&handle, true, |_| {
// Set the worker context.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:15 | while !core.is_shutdown {
self.assert_lifo_enabled_is_correct(&core);
if core.is_traced {
core = self.worker.handle.trace_core(core);
}
// Increment the tick
core.tick();
// Run maintenance, if needed
core = self.main... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:16 | #[cfg(all(tokio_unstable, feature = "time"))]
{
match self.worker.handle.timer_flavor {
TimerFlavor::Traditional => {}
TimerFlavor::Alternative => {
util::time_alt::shutdown_local_timers(
&mut core.time_context.wheel,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:17 | //
// Note that this explicitly checks `cfg!(tokio_unstable)` in addition,
// as that should result in this whole expression being eliminated at
// compile-time when unstable features are disabled.
if cfg!(tokio_unstable)
&& core.enable_eager_driver_handoff
&& cor... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:18 | let mut lifo_polls = 0;
// As long as there is budget remaining and a task exists in the
// `lifo_slot`, then keep running.
loop {
// Check if we still have the core. If not, the core was stolen
// by another worker.
let mut core = mat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:19 | return Ok(core);
}
// Track that we are about to run a task from the LIFO slot.
lifo_polls += 1;
super::counters::inc_lifo_schedules();
// Disable the LIFO slot if we reach our limit
//
// In ping-ping styl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:20 | fn reset_lifo_enabled(&self, core: &mut Core) {
core.lifo_enabled = !self.worker.handle.shared.config.disable_lifo_slot;
}
fn assert_lifo_enabled_is_correct(&self, core: &Core) {
debug_assert_eq!(
core.lifo_enabled,
!self.worker.handle.shared.config.disable_lifo_slot
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:21 | /// after all the IOs get dispatched
fn park(&self, mut core: Box<Core>) -> Box<Core> {
if let Some(f) = &self.worker.handle.shared.config.before_park {
f();
}
if core.transition_to_parked(&self.worker) {
while !core.is_shutdown && !core.is_traced {
c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:22 | // Store `core` in context
*self.core.borrow_mut() = Some(core);
#[cfg(feature = "time")]
let (duration, auto_advance_duration) = match self.worker.handle.timer_flavor {
TimerFlavor::Traditional => (duration, None::<Duration>),
#[cfg(tokio_unstable)]
TimerFla... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:23 | // See comments in `Handle::schedule_local` for more details.
self.maintain_local_timers_after_parking(auto_advance_duration);
}
}
// Remove `core` from context
core = self.core.borrow_mut().take().expect("core missing");
// Place `park` back in `core`
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:24 | fn maintain_local_timers_before_parking(
&self,
park_duration: Option<Duration>,
) -> MaintainLocalTimer {
let handle = &self.worker.handle;
let mut wake_queue = time_alt::WakeQueue::new();
let (should_yield, next_timer) = with_current(|maybe_cx| {
let cx = maybe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:25 | if should_yield {
MaintainLocalTimer {
park_duration: Some(Duration::from_millis(0)),
auto_advance_duration: None,
}
} else {
// get the minimum duration
let dur = util::time_alt::min_duration(park_duration, next_timer);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:26 | let mut maybe_core = cx.core.borrow_mut();
let core = maybe_core.as_mut().expect("core missing");
let time_cx = &mut core.time_context;
util::time_alt::post_auto_advance(&handle.driver, auto_advance_duration);
util::time_alt::process_expired_timers(
&mut ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:27 | #[cfg(tokio_unstable)]
pub(crate) fn worker_index(&self) -> usize {
self.worker.index
}
}
impl Core {
/// Increment the tick
fn tick(&mut self) {
self.tick = self.tick.wrapping_add(1);
}
/// Return the next notified task available to this worker.
fn next_task(&mut self, wor... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:28 | // `None`, this may be different from `max_capacity()` if
// another worker is currently stealing tasks from us.
self.run_queue.remaining_slots(),
// We want to make sure that all of the tasks we take end up in
// the first half of the local queue. This en... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:29 | }
}
fn next_local_task(&mut self) -> Option<Notified> {
self.run_queue.pop_lifo().or_else(|| self.run_queue.pop())
}
/// Function responsible for stealing tasks from another worker
///
/// Note: Only if less than half the workers are searching for tasks to steal
/// a new worker wi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:30 | }
fn transition_to_searching(&mut self, worker: &Worker) -> bool {
if !self.is_searching {
self.is_searching = worker.handle.shared.idle.transition_worker_to_searching();
}
self.is_searching
}
fn transition_from_searching(&mut self, worker: &Worker) -> bool {
i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:31 | // When the final worker transitions **out** of searching to parked, it
// must check all the queues one last time in case work materialized
// between the last work scan and transitioning out of searching.
let is_last_searcher = worker.handle.shared.idle.transition_worker_to_parked(
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:32 | .shared
.idle
.is_parked(&worker.handle.shared, worker.index)
{
return false;
}
// When unparked, the worker is in the searching state.
self.is_searching = true;
true
}
/// Runs maintenance work such as checking the pool's state.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:33 | .owned
.close_and_shutdown_all(start as usize);
self.stats
.submit(&worker.handle.shared.worker_metrics[worker.index]);
}
/// Shuts down the core.
fn shutdown(&mut self, handle: &Handle) {
// Take the core
let mut park = self.park.take().expect("park missing... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:34 | if let Some(cx) = maybe_cx {
// Make sure the task is part of the **current** scheduler.
if self.ptr_eq(&cx.worker.handle) {
// And the current thread still holds a core
if let Some(core) = cx.core.borrow_mut().as_mut() {
se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | 203af021261ab7399c18ab12f22c24f1934c7d42 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/worker.rs | 1,321 | 1,380 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.