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_alt/worker.rs:15 | // First try to acquire an available core
if let Some(core) = self.try_acquire_available_core(cx, &mut synced) {
// Try to poll a task from the global queue
let maybe_task = cx.shared().next_remote_task_synced(&mut synced);
(maybe_task, core)
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:16 | Err(())
}
// Try to acquire an available core, but do not block the thread
fn try_acquire_available_core(
&mut self,
cx: &Context,
synced: &mut Synced,
) -> Option<Box<Core>> {
if let Some(mut core) = cx
.shared()
.idle
.try_acquire_av... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:17 | if let Some(core) = synced.assigned_cores[cx.index].take() {
break core;
}
// If shutting down, abort
if cx.shared().inject.is_closed(&synced.inject) {
self.shutdown_clear_defer(cx);
return Err(());
}
synced = ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:18 | // Update shutdown state while locked
self.update_global_flags(cx, synced);
}
/// Finds the next task to run, this could be from a queue or stealing. If
/// none are available, the thread sleeps and tries again.
fn next_task(&mut self, cx: &Context, mut core: Box<Core>) -> NextTaskResult {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:19 | // driver, steal from other workers, and check the global queue
// again.
core = try_task_new_batch!(self, self.search_for_work(cx, core));
debug_assert!(cx.defer.borrow().is_empty());
core = try_task_new_batch!(self, self.park(cx, core));
}
// Shutting ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:20 | }
let mut synced = cx.shared().synced.lock();
cx.shared().next_remote_task_synced(&mut synced)
}
fn next_remote_task_batch(&self, cx: &Context, mut core: Box<Core>) -> NextTaskResult {
if cx.shared().inject.is_empty() {
return Ok((None, core));
}
// Other t... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:21 | cx.shared().inject.len() / cx.shared().remotes.len() + 1
};
let n = usize::min(n, max) + 1;
// safety: passing in the correct `inject::Synced`.
let mut tasks = unsafe { cx.shared().inject.pop_n(&mut synced.inject, n) };
// Pop the first task to return immediately
let r... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:22 | // core = try_task!(self, self.poll_driver(cx, core));
// Get a snapshot of which workers are idle
cx.shared().idle.snapshot(&mut self.idle_snapshot);
let num = cx.shared().remotes.len();
for i in 0..ROUNDS {
// Start from a random worker
let start = core.rand.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:23 | continue;
}
let target = &cx.shared().remotes[i];
if let Some(task) = target
.steal
.steal_into(&mut core.run_queue, &mut core.stats)
{
return Some(task);
}
}
None
}
fn run_task(&mut s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:24 | task.run();
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.
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:25 | // 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 style workloads where task A notifies task B,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:26 | if !defer.is_empty() {
let mut synced = synced();
// Number of tasks we want to try to spread across idle workers
let num_fanout = cmp::min(defer.len(), cx.shared().idle.num_idle(&synced.idle));
// Cap the number of threads woken up at one time. This is to limit
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:27 | cx.shared().notify_parked_local();
}
Ok((task, core))
}
fn schedule_deferred_without_core<'a>(&mut self, cx: &Context, synced: &mut Synced) {
let mut defer = cx.defer.borrow_mut();
let num = defer.len();
if num > 0 {
// Push all tasks to the injection queue... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:28 | Ok((None, core))
}
fn flush_metrics(&self, cx: &Context, core: &mut Core) {
core.stats.submit(&cx.shared().worker_metrics[core.index]);
}
fn update_global_flags(&mut self, cx: &Context, synced: &mut Synced) {
if !self.is_shutdown {
self.is_shutdown = cx.shared().inject.is_c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:29 | // to run without actually putting the thread to sleep.
if let Some(mut driver) = cx.shared().driver.take() {
driver.park_timeout(&cx.handle.driver, Duration::from_millis(0));
cx.shared().driver.set(driver);
// If there are more I/O events, schedule them.
self.s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:30 | #[cfg(not(loom))]
debug_assert!(core.run_queue.is_empty());
// Try one last time to get tasks
let n = cmp::max(core.run_queue.remaining_slots() / 2, 1);
if let Some(task) = self.next_remote_task_batch_synced(cx, &mut synced, &mut core, n) {
return Ok((Some(task), core));
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:31 | // cx.shared().idle.snapshot(&mut self.idle_snapshot);
// We were the last searching worker, we need to do one last check
for i in 0..cx.shared().remotes.len() {
if !cx.shared().remotes[i].steal.is_empty() {
let mut synced = cx.shared().synced.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:32 | // Schedule any deferred tasks
self.schedule_deferred_without_core(cx, &mut synced);
// Wait for a core.
self.wait_for_core(cx, synced)
}
} else {
synced = cx.shared().synced.lock();
// Wait for a core to be assigned to us
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:33 | fn reset_lifo_enabled(&self, cx: &Context) {
cx.lifo_enabled
.set(!cx.handle.shared.config.disable_lifo_slot);
}
fn assert_lifo_enabled_is_correct(&self, cx: &Context) {
debug_assert_eq!(
cx.lifo_enabled.get(),
!cx.handle.shared.config.disable_lifo_slot
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:34 | #[cfg_attr(not(feature = "time"), allow(dead_code))]
pub(crate) fn get_worker_index(&self) -> usize {
self.index
}
}
impl Core {
fn next_local_task(&mut self) -> Option<Notified> {
self.next_lifo_task().or_else(|| self.run_queue.pop())
}
fn next_lifo_task(&mut self) -> Option<Notif... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:35 | cx.defer.borrow_mut().push(task);
}
return;
}
}
// Otherwise, use the inject queue.
self.schedule_remote(task);
})
}
fn schedule_local(&self, cx: &Context, core: &mut Core, task: Notified) {
core.stats.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:36 | self.scheduler_metrics.inc_remote_schedule_count();
let mut synced = self.synced.lock();
// Push the task in the
self.push_remote_task(&mut synced, task);
// Notify a worker. The mutex is passed in and will be released as part
// of the method call.
self.idle.notify_rem... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:37 | where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
self.inject.push_batch(self, iter);
}
}
fn push_remote_task_batch_synced<I>(&self, synced: &mut Synced, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:38 | }
pub(super) fn shutdown_finalize(&self, handle: &Handle, synced: &mut Synced) {
// Wait for all cores
if synced.shutdown_cores.len() != self.remotes.len() {
return;
}
let driver = synced.shutdown_driver.take();
if self.driver_enabled() && driver.is_none() {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:39 | self.push_remote_task(&mut self.synced.lock(), task);
}
fn push_batch<I>(&self, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
self.push_remote_task_batch(iter)
}
}
impl<'a> Lock<inject::Synced> for &'a Shared {
type Handle = SyncedGuard<'a>;
fn lock(sel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,521 | 1,580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:40 | fn hooks(&self) -> TaskHarnessScheduleHooks {
TaskHarnessScheduleHooks {
task_terminate_callback: self.task_hooks.task_terminate_callback.clone(),
}
}
fn yield_now(&self, task: Notified) {
self.shared.schedule_task(task, true);
}
}
impl AsMut<Synced> for Synced {
fn... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,561 | 1,602 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/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 | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:4 | /// The worker-local run queue.
run_queue: queue::Local<Arc<Handle>>,
/// True if the worker is currently searching for more work. Searching
/// involves attempting to steal from other workers.
pub(super) is_searching: bool,
/// Per-worker runtime stats
stats: Stats,
/// Fast random numbe... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:5 | pub(super) condvars: Vec<Condvar>,
/// The number of cores that have observed the trace signal.
pub(super) trace_status: TraceStatus,
/// Scheduler configuration options
config: Config,
/// Collects metrics from the runtime.
pub(super) scheduler_metrics: SchedulerMetrics,
pub(super) work... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:6 | }
/// Used to communicate with a worker from other threads.
struct Remote {
/// When a task is scheduled from a worker, it is stored in this slot. The
/// worker will check this slot for a task **before** checking the run
/// queue. This effectively results in the **last** scheduled task to be run
/// ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:7 | type RunResult = Result<Box<Core>, ()>;
type NextTaskResult = Result<(Option<Notified>, Box<Core>), ()>;
/// A task handle
type Task = task::Task<Arc<Handle>>;
/// A notified task handle
type Notified = task::Notified<Arc<Handle>>;
/// Value picked out of thin-air. Running the LIFO slot a handful of times
/// seems ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:8 | let metrics = WorkerMetrics::from_config(&config);
let stats = Stats::new(&metrics);
cores.push(Box::new(Core {
index: i,
lifo_slot: None,
run_queue,
is_searching: false,
stats,
rand: FastRand::from_seed(config.seed_generator.next_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:9 | trace_status: TraceStatus::new(num_cores),
config,
scheduler_metrics: SchedulerMetrics::new(),
worker_metrics: worker_metrics.into_boxed_slice(),
_counters: Counters,
},
driver: driver_handle,
blocking_spawner,
seed_generator,
});
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:10 | if let Some(cx) = maybe_cx {
let core = cx.handoff_core.take();
let mut cx_core = cx.core.borrow_mut();
assert!(cx_core.is_none());
*cx_core = core;
// Reset the task budget as we are re-entering the
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:11 | // LocalSet, where it is _not_ okay to block.
return Err(
"can call blocking only when running on the multi-threaded runtime",
);
}
}
(context::EnterRuntime::NotEntered, true) => {
// This is a nested... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:12 | runtime::spawn_blocking(move || run(index, handle, handoff_core, true));
Ok(())
});
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.
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:13 | let num_workers = handle.shared.condvars.len();
let mut worker = Worker {
tick: 0,
num_seq_local_queue_polls: 0,
global_queue_interval: Stats::DEFAULT_GLOBAL_QUEUE_INTERVAL,
is_shutdown: false,
is_traced: false,
workers_to_notify: Vec::with_capacity(num_workers - 1),... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:14 | worker.schedule_deferred_without_core(&cx, &mut cx.shared().synced.lock());
}
});
});
}
macro_rules! try_task {
($e:expr) => {{
let (task, core) = $e?;
if task.is_some() {
return Ok((task, core));
}
core
}};
}
macro_rules! try_task_new_batch ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:16 | }
// Try to acquire an available core, but do not block the thread
fn try_acquire_available_core(
&mut self,
cx: &Context,
synced: &mut Synced,
) -> Option<Box<Core>> {
if let Some(mut core) = cx
.shared()
.idle
.try_acquire_available_core... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:17 | break core;
}
// If shutting down, abort
if cx.shared().inject.is_closed(&synced.inject) {
self.shutdown_clear_defer(cx);
return Err(());
}
synced = cx.shared().condvars[cx.index].wait(synced).unwrap();
};
sel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:18 | // Update shutdown state while locked
self.update_global_flags(cx, synced);
}
/// Finds the next task to run, this could be from a queue or stealing. If
/// none are available, the thread sleeps and tries again.
fn next_task(&mut self, cx: &Context, mut core: Box<Core>) -> NextTaskResult {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:19 | // again.
core = try_task_new_batch!(self, self.search_for_work(cx, core));
debug_assert!(cx.defer.borrow().is_empty());
core = try_task_new_batch!(self, self.park(cx, core));
}
// Shutting down, drop any deferred tasks
self.shutdown_clear_defer(cx);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:20 | let mut synced = cx.shared().synced.lock();
cx.shared().next_remote_task_synced(&mut synced)
}
fn next_remote_task_batch(&self, cx: &Context, mut core: Box<Core>) -> NextTaskResult {
if cx.shared().inject.is_empty() {
return Ok((None, core));
}
// Other threads can ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:21 | };
let n = usize::min(n, max) + 1;
// safety: passing in the correct `inject::Synced`.
let mut tasks = unsafe { cx.shared().inject.pop_n(&mut synced.inject, n) };
// Pop the first task to return immediately
let ret = tasks.next();
// Push the rest of the on the run qu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:22 | // core = try_task!(self, self.poll_driver(cx, core));
// Get a snapshot of which workers are idle
cx.shared().idle.snapshot(&mut self.idle_snapshot);
let num = cx.shared().remotes.len();
for i in 0..ROUNDS {
// Start from a random worker
let start = core.rand.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:23 | }
let target = &cx.shared().remotes[i];
if let Some(task) = target
.steal
.steal_into(&mut core.run_queue, &mut core.stats)
{
return Some(task);
}
}
None
}
fn run_task(&mut self, cx: &Context, mut... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:24 | 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 | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:25 | // 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 style workloads where task A notifies task B,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:26 | if !defer.is_empty() {
let mut synced = synced();
// Number of tasks we want to try to spread across idle workers
let num_fanout = cmp::min(defer.len(), cx.shared().idle.num_idle(&synced.idle));
// Cap the number of threads woken up at one time. This is to limit
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:27 | }
Ok((task, core))
}
fn schedule_deferred_without_core<'a>(&mut self, cx: &Context, synced: &mut Synced) {
let mut defer = cx.defer.borrow_mut();
let num = defer.len();
if num > 0 {
// Push all tasks to the injection queue
cx.shared()
.p... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:28 | Ok((None, core))
}
fn flush_metrics(&self, cx: &Context, core: &mut Core) {
core.stats.submit(&cx.shared().worker_metrics[core.index]);
}
fn update_global_flags(&mut self, cx: &Context, synced: &mut Synced) {
if !self.is_shutdown {
self.is_shutdown = cx.shared().inject.is_c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:29 | if let Some(mut driver) = cx.shared().driver.take() {
driver.park_timeout(&cx.handle.driver, Duration::from_millis(0));
cx.shared().driver.set(driver);
// If there are more I/O events, schedule them.
self.schedule_deferred_with_core(cx, core, || cx.shared().synced.lock(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:30 | debug_assert!(core.run_queue.is_empty());
// Try one last time to get tasks
let n = cmp::max(core.run_queue.remaining_slots() / 2, 1);
if let Some(task) = self.next_remote_task_batch_synced(cx, &mut synced, &mut core, n) {
return Ok((Some(task), core));
}
if !was_se... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:31 | // We were the last searching worker, we need to do one last check
for i in 0..cx.shared().remotes.len() {
if !cx.shared().remotes[i].steal.is_empty() {
let mut synced = cx.shared().synced.lock();
// Try to get a core
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:32 | self.schedule_deferred_without_core(cx, &mut synced);
// Wait for a core.
self.wait_for_core(cx, synced)
}
} else {
synced = cx.shared().synced.lock();
// Wait for a core to be assigned to us
self.wait_for_core(cx, synced)
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:33 | cx.lifo_enabled
.set(!cx.handle.shared.config.disable_lifo_slot);
}
fn assert_lifo_enabled_is_correct(&self, cx: &Context) {
debug_assert_eq!(
cx.lifo_enabled.get(),
!cx.handle.shared.config.disable_lifo_slot
);
}
fn tune_global_queue_interval(&mut s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:34 | pub(crate) fn get_worker_index(&self) -> usize {
self.index
}
}
impl Core {
fn next_local_task(&mut self) -> Option<Notified> {
self.next_lifo_task().or_else(|| self.run_queue.pop())
}
fn next_lifo_task(&mut self) -> Option<Notified> {
self.lifo_slot.take()
}
}
impl Shared... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:35 | }
return;
}
}
// Otherwise, use the inject queue.
self.schedule_remote(task);
})
}
fn schedule_local(&self, cx: &Context, core: &mut Core, task: Notified) {
core.stats.inc_local_schedule_count();
if cx.lifo_enable... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:36 | let mut synced = self.synced.lock();
// Push the task in the
self.push_remote_task(&mut synced, task);
// Notify a worker. The mutex is passed in and will be released as part
// of the method call.
self.idle.notify_remote(synced, self);
}
pub(super) fn close(&self, hand... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:37 | I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
self.inject.push_batch(self, iter);
}
}
fn push_remote_task_batch_synced<I>(&self, synced: &mut Synced, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
self... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:38 | pub(super) fn shutdown_finalize(&self, handle: &Handle, synced: &mut Synced) {
// Wait for all cores
if synced.shutdown_cores.len() != self.remotes.len() {
return;
}
let driver = synced.shutdown_driver.take();
if self.driver_enabled() && driver.is_none() {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:39 | }
fn push_batch<I>(&self, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
self.push_remote_task_batch(iter)
}
}
impl<'a> Lock<inject::Synced> for &'a Shared {
type Handle = SyncedGuard<'a>;
fn lock(self) -> Self::Handle {
SyncedGuard {
loc... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,521 | 1,580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:40 | TaskHarnessScheduleHooks {
task_terminate_callback: self.task_hooks.task_terminate_callback.clone(),
}
}
fn yield_now(&self, task: Notified) {
self.shared.schedule_task(task, true);
}
}
impl AsMut<Synced> for Synced {
fn as_mut(&mut self) -> &mut Synced {
self
}... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b8ac94ed70df22f885bad7ea3c0ff51c536bad4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b8ac94ed70df22f885bad7ea3c0ff51c536bad4a/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,561 | 1,601 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:8 | let metrics = WorkerMetrics::from_config(&config);
let stats = Stats::new(&metrics);
cores.push(Box::new(Core {
index: i,
lifo_slot: None,
run_queue,
is_searching: false,
stats,
rand: FastRand::from_seed(config.seed_generator.next_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:9 | }),
driver: AtomicCell::new(Some(Box::new(driver))),
condvars: (0..num_workers).map(|_| Condvar::new()).collect(),
trace_status: TraceStatus::new(num_cores),
config,
scheduler_metrics: SchedulerMetrics::new(),
worker_metrics: worker_metrics.into_bo... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:10 | impl Drop for Reset {
fn drop(&mut self) {
with_current(|maybe_cx| {
if let Some(cx) = maybe_cx {
let core = cx.handoff_core.take();
let mut cx_core = cx.core.borrow_mut();
assert!(cx_core.is_none());
*cx... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:11 | return Ok(());
} else {
// This probably means we are on the current_thread runtime or in a
// LocalSet, where it is _not_ okay to block.
return Err(
"can call blocking only when running on the multi-threaded runtime",
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:12 | let index = cx.index;
let handle = cx.handle.clone();
let handoff_core = cx.handoff_core.clone();
runtime::spawn_blocking(move || run(index, handle, handoff_core, true));
Ok(())
});
if let Err(panic_message) = setup_result {
panic!("{}", panic_message);
}
if had... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:13 | // debug assertions are enabled, we just abort the process.
#[cfg(debug_assertions)]
let _abort_on_panic = AbortOnPanic;
let num_workers = handle.shared.condvars.len();
let mut worker = Worker {
tick: 0,
num_seq_local_queue_polls: 0,
global_queue_interval: Stats::DEFAULT_GLOBAL... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:14 | // the worker core is lost due to `block_in_place()` being called from
// within the task.
if !cx.defer.borrow().is_empty() {
worker.schedule_deferred_without_core(&cx, &mut cx.shared().synced.lock());
}
});
});
}
macro_rules! try_task {
($e:expr) => ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:15 | } else {
let mut synced = cx.shared().synced.lock();
// First try to acquire an available core
if let Some(core) = self.try_acquire_available_core(cx, &mut synced) {
// Try to poll a task from the global queue
let maybe_task = cx.s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:16 | self.shutdown_clear_defer(cx);
Err(())
}
// Try to acquire an available core, but do not block the thread
fn try_acquire_available_core(
&mut self,
cx: &Context,
synced: &mut Synced,
) -> Option<Box<Core>> {
if let Some(mut core) = cx
.shared()
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:17 | // Wait until a core is available, then exit the loop.
let mut core = loop {
if let Some(core) = synced.assigned_cores[cx.index].take() {
break core;
}
// If shutting down, abort
if cx.shared().inject.is_closed(&synced.inject) {
se... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:18 | #[cfg(not(loom))]
debug_assert!(core.run_queue.is_empty());
// Update shutdown state while locked
self.update_global_flags(cx, synced);
}
/// Finds the next task to run, this could be from a queue or stealing. If
/// none are available, the thread sleeps and tries again.
fn nex... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:19 | while !self.is_shutdown {
// Search for more work, this involves trying to poll the resource
// driver, steal from other workers, and check the global queue
// again.
core = try_task_new_batch!(self, self.search_for_work(cx, core));
debug_assert!(cx.defer.bor... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:20 | if cx.shared().inject.is_empty() {
return None;
}
let mut synced = cx.shared().synced.lock();
cx.shared().next_remote_task_synced(&mut synced)
}
fn next_remote_task_batch(&self, cx: &Context, mut core: Box<Core>) -> NextTaskResult {
if cx.shared().inject.is_empty() ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:21 | cx.shared().inject.len() / cx.shared().idle.num_searching() + 1
} else {
cx.shared().inject.len() / cx.shared().remotes.len() + 1
};
let n = usize::min(n, max) + 1;
// safety: passing in the correct `inject::Synced`.
let mut tasks = unsafe { cx.shared().inject.pop_n... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:22 | return Ok((None, core));
}
// core = try_task!(self, self.poll_driver(cx, core));
// Get a snapshot of which workers are idle
cx.shared().idle.snapshot(&mut self.idle_snapshot);
let num = cx.shared().remotes.len();
for i in 0..ROUNDS {
// Start from a rand... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:23 | // If the core is currently idle, then there is nothing to steal.
if self.idle_snapshot.is_idle(i) {
continue;
}
let target = &cx.shared().remotes[i];
if let Some(task) = target
.steal
.steal_into(&mut core.run_queue, &mut... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:24 | coop::budget(|| {
super::counters::inc_num_polls();
task.run();
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. ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:25 | 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 | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:26 | return Ok((None, core));
}
if !defer.is_empty() {
let mut synced = synced();
// Number of tasks we want to try to spread across idle workers
let num_fanout = cmp::min(defer.len(), cx.shared().idle.num_idle(&synced.idle));
// Cap the number of threads wo... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:27 | }
cx.shared().notify_parked_local();
}
Ok((task, core))
}
fn schedule_deferred_without_core<'a>(&mut self, cx: &Context, synced: &mut Synced) {
let mut defer = cx.defer.borrow_mut();
let num = defer.len();
if num > 0 {
// Push all tasks to the ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:28 | core.stats.start_processing_scheduled_tasks(&mut self.stats);
}
Ok((None, core))
}
fn flush_metrics(&self, cx: &Context, core: &mut Core) {
core.stats.submit(&cx.shared().worker_metrics[core.index]);
}
fn update_global_flags(&mut self, cx: &Context, synced: &mut Synced) {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:29 | fn poll_driver(&mut self, cx: &Context, core: Box<Core>) -> NextTaskResult {
// Call `park` with a 0 timeout. This enables the I/O driver, timer, ...
// to run without actually putting the thread to sleep.
if let Some(mut driver) = cx.shared().driver.take() {
driver.park_timeout(&cx.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:30 | // The local queue should be empty at this point
#[cfg(not(loom))]
debug_assert!(core.run_queue.is_empty());
// Try one last time to get tasks
let n = cmp::max(core.run_queue.remaining_slots() / 2, 1);
if let Some(task) = self.next_remote_task_batch_synced(cx, &mut synced, &mut ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:31 | if was_searching {
if cx.shared().idle.transition_worker_from_searching() {
// cx.shared().idle.snapshot(&mut self.idle_snapshot);
// We were the last searching worker, we need to do one last check
for i in 0..cx.shared().remotes.len() {
if... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:32 | self.schedule_deferred_with_core(cx, core, move || synced)
} else {
// Schedule any deferred tasks
self.schedule_deferred_without_core(cx, &mut synced);
// Wait for a core.
self.wait_for_core(cx, synced)
}
} else {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:33 | }
fn reset_lifo_enabled(&self, cx: &Context) {
cx.lifo_enabled
.set(!cx.handle.shared.config.disable_lifo_slot);
}
fn assert_lifo_enabled_is_correct(&self, cx: &Context) {
debug_assert_eq!(
cx.lifo_enabled.get(),
!cx.handle.shared.config.disable_lifo_slo... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:34 | }
#[cfg_attr(not(feature = "time"), allow(dead_code))]
pub(crate) fn get_worker_index(&self) -> usize {
self.index
}
}
impl Core {
fn next_local_task(&mut self) -> Option<Notified> {
self.next_lifo_task().or_else(|| self.run_queue.pop())
}
fn next_lifo_task(&mut self) -> Optio... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:35 | // (`block_in_place`) or the notification happens from
// the driver.
cx.defer.borrow_mut().push(task);
}
return;
}
}
// Otherwise, use the inject queue.
self.schedule_remote(task... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:36 | fn schedule_remote(&self, task: Notified) {
super::counters::inc_num_notify_remote();
self.scheduler_metrics.inc_remote_schedule_count();
let mut synced = self.synced.lock();
// Push the task in the
self.push_remote_task(&mut synced, task);
// Notify a worker. The mutex... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:37 | fn push_remote_task_batch<I>(&self, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
self.inject.push_batch(self, iter);
}
}
fn push_remote_task_batch_synced<I>(&self, synced: &mut Synced, iter: I)
where
I: Iterator<Item = task::... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:38 | self.shutdown_finalize(handle, &mut synced);
}
pub(super) fn shutdown_finalize(&self, handle: &Handle, synced: &mut Synced) {
// Wait for all cores
if synced.shutdown_cores.len() != self.remotes.len() {
return;
}
let driver = synced.shutdown_driver.take();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:39 | impl Overflow<Arc<Handle>> for Shared {
fn push(&self, task: task::Notified<Arc<Handle>>) {
self.push_remote_task(&mut self.synced.lock(), task);
}
fn push_batch<I>(&self, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
self.push_remote_task_batch(iter)
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,521 | 1,580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:40 | }
fn hooks(&self) -> TaskHarnessScheduleHooks {
TaskHarnessScheduleHooks {
task_terminate_callback: self.task_hooks.task_terminate_callback.clone(),
}
}
fn yield_now(&self, task: Notified) {
self.shared.schedule_task(task, true);
}
}
impl AsMut<Synced> for Synced {... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,561 | 1,604 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/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 | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:8 | let metrics = WorkerMetrics::from_config(&config);
let stats = Stats::new(&metrics);
cores.push(Box::new(Core {
index: i,
lifo_slot: None,
run_queue,
is_searching: false,
stats,
rand: FastRand::from_seed(config.seed_generator.next_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:9 | config,
scheduler_metrics: SchedulerMetrics::new(),
worker_metrics: worker_metrics.into_boxed_slice(),
_counters: Counters,
},
driver: driver_handle,
blocking_spawner,
seed_generator,
});
let rt_handle = runtime::Handle {
inner: schedu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:10 | let core = cx.handoff_core.take();
let mut cx_core = cx.core.borrow_mut();
assert!(cx_core.is_none());
*cx_core = core;
// Reset the task budget as we are re-entering the
// runtime.
coop::set(self.0... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 361 | 420 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.