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:28 | 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_closed(&synced.inject);
}
if !self.is_traced {
self.is_traced = c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 there are more I/O events, schedule them.
self.schedule_deferred_with_core(cx, core, || cx.shared().synced.lock())
} else {
Ok((None, core))
}
}
*/
fn park(&mut self, cx: &Context, mut core: Box<Core>) -> NextTaskResult {
if let Some(f) = &cx.shared().c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 | if let Some(task) = self.next_remote_task_batch_synced(cx, &mut synced, &mut core, n) {
return Ok((Some(task), core));
}
if !was_searching {
if cx
.shared()
.idle
.transition_worker_to_searching_if_needed(&mut synced.idle, &mut cor... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 | // Try to get a core
if let Some(mut core) = self.try_acquire_available_core(cx, &mut synced) {
cx.shared().idle.transition_worker_to_searching(&mut core);
return Ok((None, core));
} else {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 | }
} else {
synced = cx.shared().synced.lock();
// Wait for a core to be assigned to us
self.wait_for_core(cx, synced)
}
}
fn transition_to_searching(&self, cx: &Context, core: &mut Core) -> bool {
if !core.is_searching {
cx.shared().idle.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 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 self, cx: &Context, core: &mut Core) {
let next = core.stats.tuned_global_queue_in... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 | self.next_lifo_task().or_else(|| self.run_queue.pop())
}
fn next_lifo_task(&mut self) -> Option<Notified> {
self.lifo_slot.take()
}
}
impl Shared {
fn next_remote_task_synced(&self, synced: &mut Synced) -> Option<Notified> {
// safety: we only have access to a valid `Synced` in this fi... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 | })
}
fn schedule_local(&self, cx: &Context, core: &mut Core, task: Notified) {
core.stats.inc_local_schedule_count();
if cx.lifo_enabled.get() {
// Push to the LIFO slot
let prev = std::mem::replace(&mut core.lifo_slot, Some(task));
// let prev = cx.shared()... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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.idle.notify_remote(synced, self);
}
pub(super) fn close(&self, handle: &Handle) {
{
let mut synced = self.synced.lock();
if let Some(driver) = self.driver.take() {
synced.shutdown_driver = Some(driver);
}
if !self.inject.close(&mut ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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_synced<I>(&self, synced: &mut Synced, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
self.inject.push_batch(&mut synced.inject, iter);
}
}
fn take_driver(&self) -> Option<Box<Driver>> {
if !self.driver_ena... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 | let driver = synced.shutdown_driver.take();
if self.driver_enabled() && driver.is_none() {
return;
}
debug_assert!(self.owned.is_empty());
for mut core in synced.shutdown_cores.drain(..) {
// Drain tasks from the local queue
while core.next_local_ta... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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<'a> Lock<inject::Synced> for &'a Shared {
type Handle = SyncedGuard<'a>;
fn lock(self) -> Self::Handle {
SyncedGuard {
lock: self.synced.lock(),
}
}
}
impl<'a> Lock<Synced> for &'a Shared {
type Handle = SyncedGuard<'a>;
fn lock(self) -> Self::Handle {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/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 | }
}
pub(crate) struct SyncedGuard<'a> {
lock: crate::loom::sync::MutexGuard<'a, Synced>,
}
impl<'a> AsMut<inject::Synced> for SyncedGuard<'a> {
fn as_mut(&mut self) -> &mut inject::Synced {
&mut self.lock.inject
}
}
impl<'a> AsMut<Synced> for SyncedGuard<'a> {
fn as_mut(&mut self) -> &mut Syn... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,561 | 1,597 |
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 spaw... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 3a4aef17b2c70d255affa51eb473efcf703896e4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a4aef17b2c70d255affa51eb473efcf703896e4/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 | 3a4aef17b2c70d255affa51eb473efcf703896e4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a4aef17b2c70d255affa51eb473efcf703896e4/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 | 3a4aef17b2c70d255affa51eb473efcf703896e4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a4aef17b2c70d255affa51eb473efcf703896e4/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 | 3a4aef17b2c70d255affa51eb473efcf703896e4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a4aef17b2c70d255affa51eb473efcf703896e4/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
/// seemms... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 3a4aef17b2c70d255affa51eb473efcf703896e4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a4aef17b2c70d255affa51eb473efcf703896e4/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 | 593dbf55d1165df9d27f81b1214eecacbb7f94dc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/593dbf55d1165df9d27f81b1214eecacbb7f94dc/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:37 | fn push_remote_task_batch_synced<I>(&self, synced: &mut Synced, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
self.inject.push_batch(&mut synced.inject, iter);
}
}
fn take_driver(&self) -> Option<Box<Driver>> {
if !self.driver_ena... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 593dbf55d1165df9d27f81b1214eecacbb7f94dc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/593dbf55d1165df9d27f81b1214eecacbb7f94dc/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 | if self.driver_enabled() && driver.is_none() {
return;
}
debug_assert!(self.owned.is_empty());
for mut core in synced.shutdown_cores.drain(..) {
// Drain tasks from the local queue
while core.next_local_task().is_some() {}
}
// Shutdown the ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 593dbf55d1165df9d27f81b1214eecacbb7f94dc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/593dbf55d1165df9d27f81b1214eecacbb7f94dc/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:14 | }
});
});
}
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 {
($w:expr, $e:expr) => {{
let (task, mut core) = $e?;
if task.is_so... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:15 | 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)
} else {
// block the t... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:20 | 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 only **remove** tasks from the current worker's
// `run_queue`. So, we can be confident that by the time... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:21 | // 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 immedietly
let ret = tasks.next();
// Push the rest of the on the run queue
core.run_queue.push_back(tasks);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:20 | 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 only **remove** tasks from the current worker's
// `run_queue`. So, we can be confident that by the time... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:21 | // 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 immedietly
let ret = tasks.next();
// Push the rest of the on the run queue
core.run_queue.push_back(tasks);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:25 | // Disable the LIFO slot if we reach our limit
//
// In ping-ping style workloads where task A notifies task B,
// which notifies task A again, continuously prioritizing the
// LIFO slot can cause starvation as these two tasks will
// repea... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | let num_fanout = cmp::min(defer.len(), cx.shared().idle.num_idle(&synced.idle));
if num_fanout > 0 {
cx.shared()
.push_remote_task_batch_synced(&mut synced, defer.drain(..num_fanout));
cx.shared()
.idle
.notify_mul... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | .push_remote_task_batch_synced(synced, defer.drain(..));
debug_assert!(self.workers_to_notify.is_empty());
// Notify workers
cx.shared()
.idle
.notify_mult(synced, &mut self.workers_to_notify, num);
// Notify any workers
for ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | if !self.is_traced {
self.is_traced = cx.shared().trace_status.trace_requested();
}
}
fn park_yield(&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 t... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 park(&mut self, cx: &Context, mut core: Box<Core>) -> NextTaskResult {
if let Some(f) = &cx.shared().config.before_park {
f();
}
if self.can_transition_to_parked(&mut core) {
debug_assert!(!self.is_shutdown);
debug_assert!(!self.is_traced);
co... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | .transition_worker_to_searching_if_needed(&mut synced.idle, &mut core)
{
// Skip parking, go back to searching
return Ok((None, core));
}
}
super::counters::inc_num_parks();
core.stats.about_to_park();
// Flush metrics to the runti... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 let Some(mut driver) = cx.shared().take_driver() {
// Wait for driver events
driver.park(&cx.handle.driver);
synced = cx.shared().synced.lock();
if cx.shared().inject.is_closed(&mut synced.inj... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | fn transition_to_searching(&self, cx: &Context, core: &mut Core) -> bool {
if !core.is_searching {
cx.shared().idle.try_transition_worker_to_searching(core);
}
core.is_searching
}
/// Returns `true` if another worker must be notified
fn transition_from_searching(&self, ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | let next = core.stats.tuned_global_queue_interval(&cx.shared().config);
debug_assert!(next > 1);
// Smooth out jitter
if abs_diff(self.global_queue_interval, next) > 2 {
self.global_queue_interval = next;
}
}
fn shutdown_clear_defer(&self, cx: &Context) {
l... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | impl Shared {
fn next_remote_task_synced(&self, synced: &mut Synced) -> Option<Notified> {
// safety: we only have access to a valid `Synced` in this file.
unsafe { self.inject.pop(&mut synced.inject) }
}
pub(super) fn schedule_task(&self, task: Notified, is_yield: bool) {
use std::... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | let prev = std::mem::replace(&mut core.lifo_slot, Some(task));
// let prev = cx.shared().remotes[core.index].lifo_slot.swap_local(task);
if let Some(prev) = prev {
core.run_queue
.push_back_or_overflow(prev, self, &mut core.stats);
} else {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | synced.shutdown_driver = Some(driver);
}
if !self.inject.close(&mut synced.inject) {
return;
}
// Set the shutdown flag on all available cores
self.idle.shutdown(&mut synced, self);
}
// Any unassigned cores need to be shutdo... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 take_driver(&self) -> Option<Box<Driver>> {
if !self.driver_enabled() {
return None;
}
self.driver.take()
}
fn driver_enabled(&self) -> bool {
self.condvars.len() > self.remotes.len()
}
pub(super) fn shutdown_core(&self, handle: &Handle, mut core: Box<Co... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | while core.next_local_task().is_some() {}
}
// Shutdown the driver
if let Some(mut driver) = driver {
driver.shutdown(&handle.driver);
}
// Drain the injection queue
//
// We already shut down every task, so we can simply drop the tasks. We
/... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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<'a> Lock<Synced> for &'a Shared {
type Handle = SyncedGuard<'a>;
fn lock(self) -> Self::Handle {
SyncedGuard {
lock: self.synced.lock(),
}
}
}
impl task::Schedule for Arc<Handle> {
fn release(&self, task: &Task) -> Option<Task> {
self.shared.owned.remove(t... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/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 | }
}
impl<'a> AsMut<Synced> for SyncedGuard<'a> {
fn as_mut(&mut self) -> &mut Synced {
&mut self.lock
}
}
#[track_caller]
fn with_current<R>(f: impl FnOnce(Option<&Context>) -> R) -> R {
use scheduler::Context::MultiThreadAlt;
context::with_scheduler(|ctx| match ctx {
Some(MultiThread... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dd23f08c3a35495b4b53defa81ec0ca2c75a5f7d/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,561 | 1,587 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:14 | }
});
});
}
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 {
($w:expr, $e:expr) => {{
let (task, mut core) = $e?;
if task.is_so... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:15 | if let Some(core) = self.try_acquire_available_core(cx, &mut synced) {
// Try to poll a task from the global queue
let maybe_task = self.next_remote_task_synced(cx, &mut synced);
(maybe_task, core)
} else {
// block the thre... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 561 | 620 |
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 | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:19 | 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);
Ok((None, core))
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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();
self.next_remote_task_synced(cx, &mut synced)
}
fn next_remote_task_synced(&self, cx: &Context, synced: &mut Synced) -> Option<Notified> {
// safety: we only have access to a valid `Synced` in this file.
unsafe { cx.shared().inject.pop(&mut sy... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 = if core.is_searching {
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 mu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:22 | debug_assert!(core.lifo_slot.is_none());
#[cfg(not(loom))]
debug_assert!(core.run_queue.is_empty());
if !core.run_queue.can_steal() {
return Ok((None, core));
}
if !self.transition_to_searching(cx, &mut core) {
return Ok((None, core));
}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:23 | for i in 0..num {
let i = (start + i) % num;
// Don't steal from ourself! We know we don't have work.
if i == core.index {
continue;
}
// If the core is currently idle, then there is nothing to steal.
if self.idle_snapshot.is_idle... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:24 | // tasks under this measurement. In this case, the tasks came from the
// LIFO slot and are considered part of the current task for scheduling
// purposes. These tasks inherent the "parent"'s limits.
core.stats.start_poll(&mut self.stats);
// Make the core available to the runtime conte... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:25 | 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, cx.shared(), &mut core.stats);
// If we hit this poi... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | mut core: Box<Core>,
synced: impl FnOnce() -> MutexGuard<'a, Synced>,
) -> NextTaskResult {
let mut defer = cx.defer.borrow_mut();
// Grab a task to run next
let task = defer.pop();
if task.is_none() {
return Ok((None, core));
}
if !defer.is_emp... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | .push_back_or_overflow(task, cx.shared(), &mut core.stats);
}
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 = ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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_timeo... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | let mut synced = cx.shared().synced.lock();
// 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... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | // This may result in a task being run
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_c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | core.lifo_slot.is_some() || !core.run_queue.is_empty()
}
/// Signals all tasks to shut down, and waits for them to complete. Must run
/// before we enter the single-threaded phase of shutdown processing.
fn pre_shutdown(&self, cx: &Context, core: &mut Core) {
// Signal to all tasks to shut down... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | }
// Shutdown the driver
if let Some(mut driver) = driver {
driver.shutdown(&cx.handle.driver);
}
// Drain the injection queue
//
// We already shut down every task, so we can simply drop the tasks. We
// cannot call `next_remote_task()` because we a... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | fn shutdown_clear_defer(&self, cx: &Context) {
let mut defer = cx.defer.borrow_mut();
for task in defer.drain(..) {
drop(task);
}
}
}
impl Context {
pub(crate) fn defer(&self, waker: &Waker) {
// TODO: refactor defer across all runtimes
waker.wake_by_ref();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | 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 | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | 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 | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | fn push_remote_task_batch_synced<I>(&self, synced: &mut Synced, iter: I)
where
I: Iterator<Item = task::Notified<Arc<Handle>>>,
{
unsafe {
self.inject.push_batch(&mut synced.inject, iter);
}
}
fn take_driver(&self) -> Option<Box<Driver>> {
if !self.driver_ena... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/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 | lock: self.synced.lock(),
}
}
}
impl task::Schedule for Arc<Handle> {
fn release(&self, task: &Task) -> Option<Task> {
self.shared.owned.remove(task)
}
fn schedule(&self, task: Notified) {
self.shared.schedule_task(task, false);
}
fn yield_now(&self, task: Notified) {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,521 | 1,567 |
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 | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:6 | 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
/// next (LIFO). This is an optimization for improving locality w... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:7 | /// 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
/// seemms sufficient to benefit from locality. More than 3 times probably is
/// overweighing. The value can be tun... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:8 | stats,
rand: FastRand::from_seed(config.seed_generator.next_seed()),
}));
remotes.push(Remote {
steal,
// lifo_slot: Lifo::new(),
});
worker_metrics.push(metrics);
}
// Allocate num-cores + 1 workers, so one worker can handle the I/O driver,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:9 | let rt_handle = runtime::Handle {
inner: scheduler::Handle::MultiThreadAlt(handle),
};
// Eagerly start worker threads
for index in 0..num_workers {
let handle = rt_handle.inner.expect_multi_thread_alt();
let h2 = handle.clone();
let handoff_core = Arc::new(AtomicCell::new(N... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 mut had_entered = false;
let setup_result = with_current(|maybe_cx| {
match (
crate::runtime::context::current_enter_context(),
maybe_cx.is_some(),
) {
(context::EnterRuntime::Entered { .. }, true) => {
// We are on a ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:11 | }
(context::EnterRuntime::NotEntered, false) => {
// We are outside of the tokio runtime, so blocking is fine.
// We can also skip all of the thread pool blocking setup steps.
return Ok(());
}
}
let cx = maybe_cx.expect("no .is_som... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:12 | // constrained by task budgets.
let _reset = Reset(coop::stop());
crate::runtime::context::exit_runtime(f)
} else {
f()
}
}
fn run(
index: usize,
handle: Arc<Handle>,
handoff_core: Arc<AtomicCell<Core>>,
blocking_in_place: bool,
) {
struct AbortOnPanic;
impl Dr... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:13 | idle_snapshot: idle::Snapshot::new(&handle.shared.idle),
stats: stats::Ephemeral::new(),
};
let sched_handle = scheduler::Handle::MultiThreadAlt(handle.clone());
crate::runtime::context::enter_runtime(&sched_handle, true, |_| {
// Set the worker context.
let cx = scheduler::Context... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:14 | return Ok((task, core));
}
core
}};
}
macro_rules! try_task_new_batch {
($w:expr, $e:expr) => {{
let (task, mut core) = $e?;
if task.is_some() {
core.stats.start_processing_scheduled_tasks(&mut $w.stats);
return Ok((task, core));
}
core
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:15 | };
core.stats.start_processing_scheduled_tasks(&mut self.stats);
if let Some(task) = maybe_task {
core = self.run_task(cx, core, task)?;
}
while !self.is_shutdown {
let (maybe_task, c) = self.next_task(cx, core)?;
core = c;
if let Some(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:16 | if let Some(mut core) = cx
.shared()
.idle
.try_acquire_available_core(&mut synced.idle)
{
self.reset_acquired_core(cx, synced, &mut core);
Some(core)
} else {
None
}
}
// Block the current thread, waiting for an av... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:17 | // Currently shutting down, don't do any more work
return Ok((None, core));
}
let n = core.run_queue.max_capacity() / 2;
let maybe_task = self.next_remote_task_batch_synced(cx, &mut synced, &mut core, n);
Ok((maybe_task, core))
}
/// Ensure core's state is set corr... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:18 | core = try_task!(self.maybe_maintenance(&cx, core));
// Check the LIFO slot, local run queue, and the injection queue for
// a notified task.
core = try_task!(self.next_notified_task(cx, core));
// We consumed all work in the queues and will start searching for work.
core.stats... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:19 | self.num_seq_local_queue_polls = 0;
// Update the global queue interval, if needed
self.tune_global_queue_interval(cx, &mut core);
if let Some(task) = self.next_remote_task(cx) {
return Ok((Some(task), core));
}
}
if let Some(task) = sel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:20 | // available slots in the queue.
let cap = usize::min(
core.run_queue.remaining_slots(),
core.run_queue.max_capacity() / 2,
);
let mut synced = cx.shared().synced.lock();
let maybe_task = self.next_remote_task_batch_synced(cx, &mut synced, &mut core, cap);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:21 | ret
}
fn next_local_task(&self, core: &mut Core) -> Option<Notified> {
self.next_lifo_task(core).or_else(|| core.run_queue.pop())
}
fn next_lifo_task(&self, core: &mut Core) -> Option<Notified> {
core.lifo_slot.take()
}
/// Function responsible for stealing tasks from another ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:22 | if let Some(task) = self.steal_one_round(cx, &mut core, start) {
return Ok((Some(task), core));
}
core = try_task!(self.next_remote_task_batch(cx, core));
if i > 0 {
super::counters::inc_num_spin_stall();
std::thread::sleep(std::time:... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:23 | }
None
}
fn run_task(&mut self, cx: &Context, mut core: Box<Core>, task: Notified) -> RunResult {
let task = cx.shared().owned.assert_owner(task);
// Make sure the worker is not in the **searching** state. This enables
// another idle worker to try to steal work.
if se... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:24 | // In this case, we cannot call `reset_lifo_enabled()`
// because the core was stolen. The stealer will handle
// that at the top of `Context::run`
return Err(());
}
};
// Check for a task in the... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread_alt/worker.rs:25 | // number of times the LIFO slot is prioritized.
if lifo_polls >= MAX_LIFO_POLLS_PER_TICK {
cx.lifo_enabled.set(false);
super::counters::inc_lifo_capped();
}
// Run the LIFO task, then loop
*cx.core.borrow_mut() = S... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | cx.shared()
.idle
.notify_mult(&mut synced, &mut self.workers_to_notify, num_fanout);
}
// Do not run the task while holding the lock...
drop(synced);
}
// Notify any workers
for worker in self.workers_to_notify.drain(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | .idle
.notify_mult(synced, &mut self.workers_to_notify, num);
// Notify any workers
for worker in self.workers_to_notify.drain(..) {
cx.shared().condvars[worker].notify_one()
}
}
}
fn maybe_maintenance(&mut self, cx: &Context, mut cor... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | // 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.handle.driver, Duration::from_millis(0));
cx.shared().driver.set(driver)... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 self.can_transition_to_parked(&mut core) {
debug_assert!(!self.is_shutdown);
debug_assert!(!self.is_traced);
core = try_task!(self.do_park(cx, core));
}
if let Some(f) = &cx.shared().config.after_unpark {
f();
}
Ok((None, core))
}... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | .idle
.transition_worker_to_searching_if_needed(&mut synced.idle, &mut core)
{
// Skip parking, go back to searching
return Ok((None, core));
}
}
super::counters::inc_num_parks();
core.stats.about_to_park();
// Flus... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | self.shutdown_finalize(cx, synced);
return Err(());
}
// Try to acquire an available core to schedule I/O events
if let Some(core) = self.try_acquire_available_core(cx, &mut synced) {
// This may result in a task being run
self.schedul... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | }
fn has_tasks(&self, core: &Core) -> bool {
core.lifo_slot.is_some() || !core.run_queue.is_empty()
}
/// Signals all tasks to shut down, and waits for them to complete. Must run
/// before we enter the single-threaded phase of shutdown processing.
fn pre_shutdown(&self, cx: &Context, core... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | // Drain tasks from the local queue
while self.next_local_task(&mut core).is_some() {}
}
// Shutdown the driver
driver.shutdown(&cx.handle.driver);
// Drain the injection queue
//
// We already shut down every task, so we can simply drop the tasks. We
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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: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 | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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 | unsafe {
self.inject.push_batch(&mut synced.inject, iter);
}
}
}
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: Iterato... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/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(crate) struct InjectGuard<'a> {
lock: crate::loom::sync::MutexGuard<'a, Synced>,
}
impl<'a> AsMut<inject::Synced> for InjectGuard<'a> {
fn as_mut(&mut self) -> &mut inject::Synced {
&mut self.lock.inject
}
}
#[track_caller]
fn with_current<R>(f: impl FnOnce(Option<&Context>) -> R) -> R {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | MIT | a58beb3aca18e6ec4cb444b6c78d5a3373742998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a58beb3aca18e6ec4cb444b6c78d5a3373742998/tokio/src/runtime/scheduler/multi_thread_alt/worker.rs | 1,481 | 1,511 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.