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/queue.rs:14 | // head but not the steal. By doing this, no other thread is able to
// steal from this queue until the current thread completes.
let res = self
.0
.head
.compare_exchange(prev_packed, next_packed, AcqRel, Acquire);
match res {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/scheduler/multi_thread/queue.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15 | .with_mut(|ptr| unsafe { ptr::write((*ptr).as_mut_ptr(), task) });
}
let mut prev_packed = next_packed;
// Update `src_head_steal` to match `src_head_real` signalling that the
// stealing routine is complete.
loop {
let head = unpack(prev_packed).1;
next... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/scheduler/multi_thread/queue.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:16 | assert!(self.pop_lifo().is_none(), "LIFO slot not empty");
}
}
}
/// Calculate the length of the queue using the head and tail.
/// The `head` can be the `steal` or `real` head.
fn len(head: UnsignedShort, tail: UnsignedShort) -> usize {
tail.wrapping_sub(head) as usize
}
/// Split the head value into... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/scheduler/multi_thread/queue.rs | 601 | 629 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3 | unsafe { Box::from_raw(Box::into_raw(buffer).cast()) }
}
/// Create a new local run-queue
pub(crate) fn local<T: 'static>() -> (Steal<T>, Local<T>) {
let mut buffer = Vec::with_capacity(LOCAL_QUEUE_CAPACITY);
for _ in 0..LOCAL_QUEUE_CAPACITY {
buffer.push(UnsafeCell::new(MaybeUninit::uninit()));
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:4 | /// Returns false if there are any entries in the queue
///
/// Separate to `is_stealable` so that refactors of `is_stealable` to "protect"
/// some tasks from stealing won't affect this
pub(crate) fn has_tasks(&self) -> bool {
!self.inner.is_empty()
}
/// Pushes a batch of tasks to the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5 | self.inner.buffer[idx].with_mut(|ptr| {
// Write the task to the slot
//
// Safety: There is only one producer and the above `if`
// condition ensures we don't touch a cell if there is a
// value, thus no consumer.
unsafe {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6 | } else if steal != real {
// Concurrently stealing, this will free up capacity, so only
// push the task onto the inject queue
overflow.push(task);
return;
} else {
// Push the current task and half of the queue into the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7 | }
/// Moves a batch of tasks into the inject queue.
///
/// This will temporarily make some of the tasks unavailable to stealers.
/// Once `push_overflow` is done, a notification is sent out, so if other
/// workers "missed" some of the tasks during a steal, they will get
/// another opportunit... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8 | // moved).
if self
.inner
.head
.compare_exchange(
prev,
pack(
head.wrapping_add(NUM_TASKS_TAKEN),
head.wrapping_add(NUM_TASKS_TAKEN),
),
Release,
Relaxed,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9 | let task = slot.with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
self.i += 1;
Some(task)
}
}
}
// safety: The CAS above ensures that no consumer will look at these
// values again, and we are the only producer.
let b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10 | // If `steal == real` there are no concurrent stealers. Both `steal`
// and `real` are updated.
let next = if steal == real {
pack(next_real, next_real)
} else {
assert_ne!(steal, next_real);
pack(steal, next_real)
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11 | // To the caller, `dst` may **look** empty but still have values
// contained in the buffer. If another thread is concurrently stealing
// from `dst` there may not be enough capacity to steal.
let (steal, _) = unpack(dst.inner.head.load(Acquire));
if dst_tail.wrapping_sub(steal) > LOCAL... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12 | Some(ret)
}
// Steal tasks from `self`, placing them into `dst`. Returns the number of
// tasks that were stolen.
fn steal_into2(&self, dst: &mut Local<T>, dst_tail: UnsignedShort) -> UnsignedShort {
let mut prev_packed = self.0.head.load(Acquire);
let mut next_packed;
let n = ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13 | .compare_exchange(prev_packed, next_packed, AcqRel, Acquire);
match res {
Ok(_) => break n,
Err(actual) => prev_packed = actual,
}
};
assert!(
n <= LOCAL_QUEUE_CAPACITY as UnsignedShort / 2,
"actual = {n}"
);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14 | // Update `src_head_steal` to match `src_head_real` signalling that the
// stealing routine is complete.
loop {
let head = unpack(prev_packed).1;
next_packed = pack(head, head);
let res = self
.0
.head
.compare_exchange... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15 | fn drop(&mut self) {
if !std::thread::panicking() {
assert!(self.pop().is_none(), "queue not empty");
}
}
}
impl<T> Inner<T> {
fn remaining_slots(&self) -> usize {
let (steal, _) = unpack(self.head.load(Acquire));
let tail = self.tail.load(Acquire);
LOCAL_QU... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 561 | 605 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7 | }
/// Moves a batch of tasks into the inject queue.
///
/// This will temporarily make some of the tasks unavailable to stealers.
/// Once `push_overflow` is done, a notification is sent out, so if other
/// workers "missed" some of the tasks during a steal, they will get
/// another opportunit... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8 | // work. This is because all tasks are pushed into the queue from the
// current thread (or memory has been acquired if the local queue handle
// moved).
if self
.inner
.head
.compare_exchange(
prev,
pack(
he... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9 | // safety: Our CAS from before has assumed exclusive ownership
// of the task pointers in this range.
let task = slot.with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
self.i += 1;
Some(task)
}
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10 | let next_real = real.wrapping_add(1);
// If `steal == real` there are no concurrent stealers. Both `steal`
// and `real` are updated.
let next = if steal == real {
pack(next_real, next_real)
} else {
assert_ne!(steal, next_real);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11 | let dst_tail = unsafe { dst.inner.tail.unsync_load() };
// To the caller, `dst` may **look** empty but still have values
// contained in the buffer. If another thread is concurrently stealing
// from `dst` there may not be enough capacity to steal.
let (steal, _) = unpack(dst.inner.head... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12 | // Make the stolen items available to consumers
dst.inner.tail.store(dst_tail.wrapping_add(n), Release);
Some(ret)
}
// Steal tasks from `self`, placing them into `dst`. Returns the number of
// tasks that were stolen.
fn steal_into2(&self, dst: &mut Local<T>, dst_tail: UnsignedShort) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13 | .0
.head
.compare_exchange(prev_packed, next_packed, AcqRel, Acquire);
match res {
Ok(_) => break n,
Err(actual) => prev_packed = actual,
}
};
assert!(
n <= LOCAL_QUEUE_CAPACITY as UnsignedShort / 2,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14 | let mut prev_packed = next_packed;
// Update `src_head_steal` to match `src_head_real` signalling that the
// stealing routine is complete.
loop {
let head = unpack(prev_packed).1;
next_packed = pack(head, head);
let res = self
.0
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15 | }
impl<T> Drop for Local<T> {
fn drop(&mut self) {
if !std::thread::panicking() {
assert!(self.pop().is_none(), "queue not empty");
}
}
}
impl<T> Inner<T> {
fn remaining_slots(&self) -> usize {
let (steal, _) = unpack(self.head.load(Acquire));
let tail = self.ta... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/scheduler/multi_thread/queue.rs | 561 | 608 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14 | let mut prev_packed = next_packed;
// Update `src_head_steal` to match `src_head_real` signalling that the
// stealing routine is complete.
loop {
let head = unpack(prev_packed).1;
next_packed = pack(head, head);
let res = self
.0
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread/queue.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:1 | //! Run-queue structures to support a work-stealing scheduler
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::Arc;
use crate::runtime::scheduler::multi_thread::{Overflow, Stats};
use crate::runtime::task;
use std::mem::{self, MaybeUninit};
use std::ptr;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Rel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 593dbf55d1165df9d27f81b1214eecacbb7f94dc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/593dbf55d1165df9d27f81b1214eecacbb7f94dc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5 | self.inner.buffer[idx].with_mut(|ptr| {
// Write the task to the slot
//
// Safety: There is only one producer and the above `if`
// condition ensures we don't touch a cell if there is a
// value, thus no consumer.
unsafe {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/scheduler/multi_thread/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3 | unsafe { Box::from_raw(Box::into_raw(buffer).cast()) }
}
/// Create a new local run-queue
pub(crate) fn local<T: 'static>() -> (Steal<T>, Local<T>) {
let mut buffer = Vec::with_capacity(LOCAL_QUEUE_CAPACITY);
for _ in 0..LOCAL_QUEUE_CAPACITY {
buffer.push(UnsafeCell::new(MaybeUninit::uninit()));
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 848482d2bb5761cd8fab3ef0dd92b8241e75e3d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/848482d2bb5761cd8fab3ef0dd92b8241e75e3d7/tokio/src/runtime/scheduler/multi_thread/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:4 | /// Returns false if there are any entries in the queue
///
/// Separate to is_stealable so that refactors of is_stealable to "protect"
/// some tasks from stealing won't affect this
pub(crate) fn has_tasks(&self) -> bool {
!self.inner.is_empty()
}
/// Pushes a batch of tasks to the bac... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 848482d2bb5761cd8fab3ef0dd92b8241e75e3d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/848482d2bb5761cd8fab3ef0dd92b8241e75e3d7/tokio/src/runtime/scheduler/multi_thread/queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3 | unsafe { Box::from_raw(Box::into_raw(buffer).cast()) }
}
/// Create a new local run-queue
pub(crate) fn local<T: 'static>() -> (Steal<T>, Local<T>) {
let mut buffer = Vec::with_capacity(LOCAL_QUEUE_CAPACITY);
for _ in 0..LOCAL_QUEUE_CAPACITY {
buffer.push(UnsafeCell::new(MaybeUninit::uninit()));
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | fb4d43017d6cb7b7cbdfbe5fc189bca0291ff215 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb4d43017d6cb7b7cbdfbe5fc189bca0291ff215/tokio/src/runtime/scheduler/multi_thread/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:1 | //! Run-queue structures to support a work-stealing scheduler
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::Arc;
use crate::runtime::scheduler::multi_thread::Stats;
use crate::runtime::scheduler::Inject;
use crate::runtime::task;
use std::mem::{self, MaybeUninit};
use std::ptr;
use std::sync::atomic::Orde... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3 | // safety: We check that the length is correct.
unsafe { Box::from_raw(Box::into_raw(buffer).cast()) }
}
/// Create a new local run-queue
pub(crate) fn local<T: 'static>() -> (Steal<T>, Local<T>) {
let mut buffer = Vec::with_capacity(LOCAL_QUEUE_CAPACITY);
for _ in 0..LOCAL_QUEUE_CAPACITY {
buffer... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:4 | }
/// Returns false if there are any entries in the queue
///
/// Separate to is_stealable so that refactors of is_stealable to "protect"
/// some tasks from stealing won't affect this
pub(crate) fn has_tasks(&self) -> bool {
!self.inner.is_empty()
}
/// Pushes a batch of tasks to ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5 | let idx = tail as usize & MASK;
self.inner.buffer[idx].with_mut(|ptr| {
// Write the task to the slot
//
// Safety: There is only one producer and the above `if`
// condition ensures we don't touch a cell if there is a
// value... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6 | break tail;
} else if steal != real {
// Concurrently stealing, this will free up capacity, so only
// push the task onto the inject queue
inject.push(task);
return;
} else {
// Push the current task and half of the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7 | self.inner.tail.store(tail.wrapping_add(1), Release);
}
/// Moves a batch of tasks into the inject queue.
///
/// This will temporarily make some of the tasks unavailable to stealers.
/// Once `push_overflow` is done, a notification is sent out, so if other
/// workers "missed" some of the task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8 | // There isn't really any need for memory ordering... Relaxed would
// work. This is because all tasks are pushed into the queue from the
// current thread (or memory has been acquired if the local queue handle
// moved).
if self
.inner
.head
.compare_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9 | // safety: Our CAS from before has assumed exclusive ownership
// of the task pointers in this range.
let task = slot.with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
self.i += 1;
Some(task)
}
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10 | let next_real = real.wrapping_add(1);
// If `steal == real` there are no concurrent stealers. Both `steal`
// and `real` are updated.
let next = if steal == real {
pack(next_real, next_real)
} else {
assert_ne!(steal, next_real);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11 | // holds a mutable reference.
let dst_tail = unsafe { dst.inner.tail.unsync_load() };
// To the caller, `dst` may **look** empty but still have values
// contained in the buffer. If another thread is concurrently stealing
// from `dst` there may not be enough capacity to steal.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12 | // Make the stolen items available to consumers
dst.inner.tail.store(dst_tail.wrapping_add(n), Release);
Some(ret)
}
// Steal tasks from `self`, placing them into `dst`. Returns the number of
// tasks that were stolen.
fn steal_into2(&self, dst: &mut Local<T>, dst_tail: UnsignedShort) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13 | let res = self
.0
.head
.compare_exchange(prev_packed, next_packed, AcqRel, Acquire);
match res {
Ok(_) => break n,
Err(actual) => prev_packed = actual,
}
};
assert!(
n <= LOCAL_QUEUE_CA... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14 | }
let mut prev_packed = next_packed;
// Update `src_head_steal` to match `src_head_real` signalling that the
// stealing routine is complete.
loop {
let head = unpack(prev_packed).1;
next_packed = pack(head, head);
let res = self
.0
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15 | }
}
impl<T> Drop for Local<T> {
fn drop(&mut self) {
if !std::thread::panicking() {
assert!(self.pop().is_none(), "queue not empty");
}
}
}
impl<T> Inner<T> {
fn remaining_slots(&self) -> usize {
let (steal, _) = unpack(self.head.load(Acquire));
let tail = self.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | a8b6353535ffa08fc84aee93d315ec4df088c2c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a8b6353535ffa08fc84aee93d315ec4df088c2c2/tokio/src/runtime/scheduler/multi_thread/queue.rs | 561 | 609 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:1 | //! Run-queue structures to support a work-stealing scheduler
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::Arc;
use crate::runtime::scheduler::multi_thread::Stats;
use crate::runtime::task::{self, Inject};
use std::mem::{self, MaybeUninit};
use std::ptr;
use std::sync::atomic::Ordering::{AcqRel, Acquire,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 79a7e78c0d4ea5f36d74a773b9023df7d6022b27 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/multi_thread/queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5 | self.inner.buffer[idx].with_mut(|ptr| {
// Write the task to the slot
//
// Safety: There is only one producer and the above `if`
// condition ensures we don't touch a cell if there is a
// value, thus no consumer.
unsafe {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 79a7e78c0d4ea5f36d74a773b9023df7d6022b27 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/multi_thread/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6 | } else if steal != real {
// Concurrently stealing, this will free up capacity, so only
// push the task onto the inject queue
inject.push(task);
return;
} else {
// Push the current task and half of the queue into the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 79a7e78c0d4ea5f36d74a773b9023df7d6022b27 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/multi_thread/queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7 | }
/// Moves a batch of tasks into the inject queue.
///
/// This will temporarily make some of the tasks unavailable to stealers.
/// Once `push_overflow` is done, a notification is sent out, so if other
/// workers "missed" some of the tasks during a steal, they will get
/// another opportunit... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 79a7e78c0d4ea5f36d74a773b9023df7d6022b27 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/multi_thread/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8 | // work. This is because all tasks are pushed into the queue from the
// current thread (or memory has been acquired if the local queue handle
// moved).
if self
.inner
.head
.compare_exchange(
prev,
pack(
he... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 79a7e78c0d4ea5f36d74a773b9023df7d6022b27 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/multi_thread/queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9 | // safety: Our CAS from before has assumed exclusive ownership
// of the task pointers in this range.
let task = slot.with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
self.i += 1;
Some(task)
}
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 79a7e78c0d4ea5f36d74a773b9023df7d6022b27 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/multi_thread/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:1 | //! Run-queue structures to support a work-stealing scheduler
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::Arc;
use crate::runtime::task::{self, Inject};
use crate::runtime::MetricsBatch;
use std::mem::{self, MaybeUninit};
use std::ptr;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 3a94eb089343e1efa9563b91e13c79a0e61b2364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a94eb089343e1efa9563b91e13c79a0e61b2364/tokio/src/runtime/scheduler/multi_thread/queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5 | self.inner.buffer[idx].with_mut(|ptr| {
// Write the task to the slot
//
// Safety: There is only one producer and the above `if`
// condition ensures we don't touch a cell if there is a
// value, thus no consumer.
unsafe {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 3a94eb089343e1efa9563b91e13c79a0e61b2364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a94eb089343e1efa9563b91e13c79a0e61b2364/tokio/src/runtime/scheduler/multi_thread/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6 | } else if steal != real {
// Concurrently stealing, this will free up capacity, so only
// push the task onto the inject queue
inject.push(task);
return;
} else {
// Push the current task and half of the queue into the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 3a94eb089343e1efa9563b91e13c79a0e61b2364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a94eb089343e1efa9563b91e13c79a0e61b2364/tokio/src/runtime/scheduler/multi_thread/queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7 | }
/// Moves a batch of tasks into the inject queue.
///
/// This will temporarily make some of the tasks unavailable to stealers.
/// Once `push_overflow` is done, a notification is sent out, so if other
/// workers "missed" some of the tasks during a steal, they will get
/// another opportunit... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 3a94eb089343e1efa9563b91e13c79a0e61b2364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a94eb089343e1efa9563b91e13c79a0e61b2364/tokio/src/runtime/scheduler/multi_thread/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9 | // safety: Our CAS from before has assumed exclusive ownership
// of the task pointers in this range.
let task = slot.with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
self.i += 1;
Some(task)
}
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 3a94eb089343e1efa9563b91e13c79a0e61b2364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a94eb089343e1efa9563b91e13c79a0e61b2364/tokio/src/runtime/scheduler/multi_thread/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10 | let next_real = real.wrapping_add(1);
// If `steal == real` there are no concurrent stealers. Both `steal`
// and `real` are updated.
let next = if steal == real {
pack(next_real, next_real)
} else {
assert_ne!(steal, next_real);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 3a94eb089343e1efa9563b91e13c79a0e61b2364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a94eb089343e1efa9563b91e13c79a0e61b2364/tokio/src/runtime/scheduler/multi_thread/queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11 | let dst_tail = unsafe { dst.inner.tail.unsync_load() };
// To the caller, `dst` may **look** empty but still have values
// contained in the buffer. If another thread is concurrently stealing
// from `dst` there may not be enough capacity to steal.
let (steal, _) = unpack(dst.inner.head... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 3a94eb089343e1efa9563b91e13c79a0e61b2364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3a94eb089343e1efa9563b91e13c79a0e61b2364/tokio/src/runtime/scheduler/multi_thread/queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3 | unsafe { Box::from_raw(Box::into_raw(buffer).cast()) }
}
/// Create a new local run-queue
pub(crate) fn local<T: 'static>() -> (Steal<T>, Local<T>) {
let mut buffer = Vec::with_capacity(LOCAL_QUEUE_CAPACITY);
for _ in 0..LOCAL_QUEUE_CAPACITY {
buffer.push(UnsafeCell::new(MaybeUninit::uninit()));
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:4 | /// Pushes a task to the back of the local queue, skipping the LIFO slot.
pub(crate) fn push_back(
&mut self,
mut task: task::Notified<T>,
inject: &Inject<T>,
metrics: &mut MetricsBatch,
) {
let tail = loop {
let head = self.inner.head.load(Acquire);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5 | //
// Safety: There is only one producer and the above `if`
// condition ensures we don't touch a cell if there is a
// value, thus no consumer.
unsafe {
ptr::write((*ptr).as_mut_ptr(), task);
}
});
// Make the task available. ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6 | head
);
let prev = pack(head, head);
// Claim a bunch of tasks
//
// We are claiming the tasks **before** reading them out of the buffer.
// This is safe because only the **current** thread is able to push new
// tasks.
//
// There isn't really a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7 | }
impl<'a, T: 'static> Iterator for BatchTaskIter<'a, T> {
type Item = task::Notified<T>;
#[inline]
fn next(&mut self) -> Option<task::Notified<T>> {
if self.i == UnsignedLong::from(NUM_TASKS_TAKEN) {
None
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8 | let idx = loop {
let (steal, real) = unpack(head);
// safety: this is the **only** thread that updates this cell.
let tail = unsafe { self.inner.tail.unsync_load() };
if real == tail {
// queue is empty
return None;
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9 | pub(crate) fn is_empty(&self) -> bool {
self.0.is_empty()
}
/// Steals half the tasks from self and place them into `dst`.
pub(crate) fn steal_into(
&self,
dst: &mut Local<T>,
dst_metrics: &mut MetricsBatch,
) -> Option<task::Notified<T>> {
// Safety: the caller ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10 | let ret_pos = dst_tail.wrapping_add(n);
let ret_idx = ret_pos as usize & MASK;
// safety: the value was written as part of `steal_into2` and not
// exposed to stealers, so no other thread can access it.
let ret = dst.inner.buffer[ret_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) }... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11 | return 0;
}
// Update the real head index to acquire the tasks.
let steal_to = src_head_real.wrapping_add(n);
assert_ne!(src_head_steal, steal_to);
next_packed = pack(src_head_steal, steal_to);
// Claim all those tasks. This is done by incrementi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12 | // Read the task
//
// safety: We acquired the task with the atomic exchange above.
let task = self.0.buffer[src_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
// Write the task to the new slot
//
// safety: `dst` queue is empty and we ar... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13 | cfg_metrics! {
impl<T> Steal<T> {
pub(crate) fn len(&self) -> usize {
self.0.len() as _
}
}
}
impl<T> Clone for Steal<T> {
fn clone(&self) -> Steal<T> {
Steal(self.0.clone())
}
}
impl<T> Drop for Local<T> {
fn drop(&mut self) {
if !std::thread::panicking... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 481 | 533 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14 | (steal as UnsignedShort, real as UnsignedShort)
}
/// Join the two head values
fn pack(steal: UnsignedShort, real: UnsignedShort) -> UnsignedLong {
(real as UnsignedLong) | ((steal as UnsignedLong) << (mem::size_of::<UnsignedShort>() * 8))
}
#[test]
fn test_local_queue_capacity() {
assert!(LOCAL_QUEUE_CAPACIT... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 1f50c57185d28a1d118adc22bf587541e3b7edcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f50c57185d28a1d118adc22bf587541e3b7edcc/tokio/src/runtime/scheduler/multi_thread/queue.rs | 521 | 533 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9 | pub(crate) fn is_empty(&self) -> bool {
self.0.is_empty()
}
/// Steals half the tasks from self and place them into `dst`.
pub(crate) fn steal_into(
&self,
dst: &mut Local<T>,
dst_metrics: &mut MetricsBatch,
) -> Option<task::Notified<T>> {
// Safety: the caller ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/scheduler/multi_thread/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10 | let ret_idx = ret_pos as usize & MASK;
// safety: the value was written as part of `steal_into2` and not
// exposed to stealers, so no other thread can access it.
let ret = dst.inner.buffer[ret_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
if n == 0 {
// The `dst`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/scheduler/multi_thread/queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11 | }
// Update the real head index to acquire the tasks.
let steal_to = src_head_real.wrapping_add(n);
assert_ne!(src_head_steal, steal_to);
next_packed = pack(src_head_steal, steal_to);
// Claim all those tasks. This is done by incrementing the "real"
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/scheduler/multi_thread/queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12 | //
// safety: We acquired the task with the atomic exchange above.
let task = self.0.buffer[src_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
// Write the task to the new slot
//
// safety: `dst` queue is empty and we are the only producer to
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/scheduler/multi_thread/queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13 | impl<T> Steal<T> {
pub(crate) fn len(&self) -> usize {
self.0.len() as _
}
}
}
impl<T> Clone for Steal<T> {
fn clone(&self) -> Steal<T> {
Steal(self.0.clone())
}
}
impl<T> Drop for Local<T> {
fn drop(&mut self) {
if !std::thread::panicking() {
as... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/scheduler/multi_thread/queue.rs | 481 | 532 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7 | }
impl<'a, T: 'static> Iterator for BatchTaskIter<'a, T> {
type Item = task::Notified<T>;
#[inline]
fn next(&mut self) -> Option<task::Notified<T>> {
if self.i == UnsignedLong::from(NUM_TASKS_TAKEN) {
None
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/queue.rs | MIT | 78fc94099bcbb9e8d550173381d4484c0438870a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/78fc94099bcbb9e8d550173381d4484c0438870a/tokio/src/runtime/scheduler/multi_thread/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:1 | use crate::runtime::{Config, MetricsBatch, WorkerMetrics};
use std::time::{Duration, Instant};
/// Per-worker statistics. This is used for both tuning the scheduler and
/// reporting runtime-level metrics/stats.
pub(crate) struct Stats {
/// The metrics batch used to report runtime-level metrics/stats to the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/stats.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:2 | impl Stats {
pub(crate) fn new(worker_metrics: &WorkerMetrics) -> Stats {
// Seed the value with what we hope to see.
let task_poll_time_ewma =
TARGET_GLOBAL_QUEUE_INTERVAL / TARGET_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL as f64;
Stats {
batch: MetricsBatch::new(worke... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/stats.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:3 | pub(crate) fn inc_local_schedule_count(&mut self) {
self.batch.inc_local_schedule_count();
}
pub(crate) fn start_processing_scheduled_tasks(&mut self) {
self.batch.start_processing_scheduled_tasks();
self.processing_scheduled_tasks_started_at = Instant::now();
self.tasks_polled... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/stats.rs | 81 | 137 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:4 | pub(crate) fn end_poll(&mut self) {
self.batch.end_poll();
}
pub(crate) fn incr_steal_count(&mut self, by: u16) {
self.batch.incr_steal_count(by);
}
pub(crate) fn incr_steal_operations(&mut self) {
self.batch.incr_steal_operations();
}
pub(crate) fn incr_overflow_count... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/stats.rs | 121 | 137 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:2 | impl Stats {
pub(crate) fn new(worker_metrics: &WorkerMetrics) -> Stats {
// Seed the value with what we hope to see.
let task_poll_time_ewma =
TARGET_GLOBAL_QUEUE_INTERVAL / TARGET_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL as f64;
Stats {
batch: MetricsBatch::new(worke... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/runtime/scheduler/multi_thread/stats.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:3 | pub(crate) fn start_processing_scheduled_tasks(&mut self) {
self.batch.start_processing_scheduled_tasks();
self.processing_scheduled_tasks_started_at = Instant::now();
self.tasks_polled_in_batch = 0;
}
pub(crate) fn end_processing_scheduled_tasks(&mut self) {
self.batch.end_pro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/runtime/scheduler/multi_thread/stats.rs | 81 | 133 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:4 | pub(crate) fn incr_steal_count(&mut self, by: u16) {
self.batch.incr_steal_count(by);
}
pub(crate) fn incr_steal_operations(&mut self) {
self.batch.incr_steal_operations();
}
pub(crate) fn incr_overflow_count(&mut self) {
self.batch.incr_overflow_count();
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/runtime/scheduler/multi_thread/stats.rs | 121 | 133 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:1 | use crate::runtime::{Config, MetricsBatch, WorkerMetrics};
use std::cmp;
use std::time::{Duration, Instant};
/// Per-worker statistics. This is used for both tuning the scheduler and
/// reporting runtime-level metrics/stats.
pub(crate) struct Stats {
/// The metrics batch used to report runtime-level metrics/sta... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | 328a02c1ce08df6e888b19c81cc81d59422af5ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/328a02c1ce08df6e888b19c81cc81d59422af5ef/tokio/src/runtime/scheduler/multi_thread/stats.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:2 | impl Stats {
pub(crate) fn new(worker_metrics: &WorkerMetrics) -> Stats {
// Seed the value with what we hope to see.
let task_poll_time_ewma =
TARGET_GLOBAL_QUEUE_INTERVAL / TARGET_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL as f64;
Stats {
batch: MetricsBatch::new(worke... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | 328a02c1ce08df6e888b19c81cc81d59422af5ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/328a02c1ce08df6e888b19c81cc81d59422af5ef/tokio/src/runtime/scheduler/multi_thread/stats.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:3 | self.batch.about_to_park();
}
pub(crate) fn inc_local_schedule_count(&mut self) {
self.batch.inc_local_schedule_count();
}
pub(crate) fn start_processing_scheduled_tasks(&mut self) {
self.batch.start_processing_scheduled_tasks();
self.processing_scheduled_tasks_started_at = In... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | 328a02c1ce08df6e888b19c81cc81d59422af5ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/328a02c1ce08df6e888b19c81cc81d59422af5ef/tokio/src/runtime/scheduler/multi_thread/stats.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:4 | self.tasks_polled_in_batch += 1;
}
pub(crate) fn end_poll(&mut self) {
self.batch.end_poll();
}
pub(crate) fn incr_steal_count(&mut self, by: u16) {
self.batch.incr_steal_count(by);
}
pub(crate) fn incr_steal_operations(&mut self) {
self.batch.incr_steal_operations();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | 328a02c1ce08df6e888b19c81cc81d59422af5ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/328a02c1ce08df6e888b19c81cc81d59422af5ef/tokio/src/runtime/scheduler/multi_thread/stats.rs | 121 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:2 | impl Stats {
pub(crate) fn new(worker_metrics: &WorkerMetrics) -> Stats {
// Seed the value with what we hope to see.
let task_poll_time_ewma =
TARGET_GLOBAL_QUEUE_INTERVAL / TARGET_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL as f64;
Stats {
batch: MetricsBatch::new(worke... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread/stats.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:1 | use crate::runtime::{Config, MetricsBatch, WorkerMetrics};
use std::cmp;
use std::time::{Duration, Instant};
/// Per-worker statistics. This is used for both tuning the scheduler and
/// reporting runtime-level metrics/stats.
pub(crate) struct Stats {
/// The metrics batch used to report runtime-level metrics/sta... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | 6cb106c3538cf527495ef5491c088d1365b14c8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6cb106c3538cf527495ef5491c088d1365b14c8e/tokio/src/runtime/scheduler/multi_thread/stats.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/stats.rs:2 | impl Stats {
pub(crate) fn new(worker_metrics: &WorkerMetrics) -> Stats {
// Seed the value with what we hope to see.
let task_poll_time_ewma =
TARGET_GLOBAL_QUEUE_INTERVAL / TARGET_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL as f64;
Stats {
batch: MetricsBatch::new(worke... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/stats.rs | MIT | 79a7e78c0d4ea5f36d74a773b9023df7d6022b27 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/79a7e78c0d4ea5f36d74a773b9023df7d6022b27/tokio/src/runtime/scheduler/multi_thread/stats.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/trace.rs:1 | use crate::loom::sync::atomic::{AtomicBool, Ordering};
use crate::loom::sync::{Barrier, Mutex};
use crate::runtime::dump::Dump;
use crate::runtime::scheduler::multi_thread::Handle;
use crate::sync::notify::Notify;
/// Tracing status of the worker.
pub(super) struct TraceStatus {
pub(super) trace_requested: AtomicB... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/trace.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/trace.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/trace.rs:2 | pub(super) fn stash_result(&self, dump: Dump) {
let _ = self.trace_result.lock().insert(dump);
self.result_ready.notify_one();
}
pub(super) fn take_result(&self) -> Option<Dump> {
self.trace_result.lock().take()
}
pub(super) async fn end_trace_request(&self, handle: &Handle) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/trace.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/trace.rs | 41 | 61 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/trace_mock.rs:1 | pub(super) struct TraceStatus {}
impl TraceStatus {
pub(super) fn new(_: usize) -> Self {
Self {}
}
pub(super) fn trace_requested(&self) -> bool {
false
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/trace_mock.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/trace_mock.rs | 1 | 11 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:2 | //! inject queue.
//!
//! The first case can only happen if the `OwnedTasks::bind` call happens before
//! or during step 1 of shutdown. In this case, the runtime will clean up the
//! task in step 3 of shutdown.
//!
//! In the latter case, the task was not spawned and the task is immediately
//! cancelled by the sp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:3 | cfg_taskdump! {
mod taskdump;
}
cfg_not_taskdump! {
mod taskdump_mock;
}
#[cfg(all(tokio_unstable, feature = "time"))]
use crate::loom::sync::atomic::AtomicBool;
#[cfg(all(tokio_unstable, feature = "time"))]
use crate::runtime::time_alt;
#[cfg(all(tokio_unstable, feature = "time"))]
use crate::runtime::sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:4 | /// When `true`, locally scheduled tasks go to the LIFO slot. When `false`,
/// they go to the back of the `run_queue`.
lifo_enabled: bool,
/// The worker-local run queue.
run_queue: queue::Local<Arc<Handle>>,
#[cfg(all(tokio_unstable, feature = "time"))]
time_context: time_alt::LocalContext,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:5 | global_queue_interval: u32,
/// Fast random number generator.
rand: FastRand,
}
/// State shared across all workers
pub(crate) struct Shared {
/// Per-worker remote state. All other workers have access to this and is
/// how they communicate between each other.
remotes: Box<[Remote]>,
/// Glo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:6 | pub(super) scheduler_metrics: SchedulerMetrics,
pub(super) worker_metrics: Box<[WorkerMetrics]>,
/// Only held to trigger some code on drop. This is used to get internal
/// runtime metrics that can be useful when doing performance
/// investigations. This does nothing (empty struct, no drop impl) unl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:7 | /// Core data
core: RefCell<Option<Box<Core>>>,
/// Tasks to wake after resource drivers are polled. This is mostly to
/// handle yielded tasks.
pub(crate) defer: Defer,
}
/// Starts the workers
pub(crate) struct Launch(Vec<Arc<Worker>>);
/// Running a task may consume the core. If the core is still ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/worker.rs:8 | // Create the local queues
for _ in 0..size {
let (steal, run_queue) = queue::local();
let park = park.clone();
let unpark = park.unpark();
let metrics = WorkerMetrics::from_config(&config);
let stats = Stats::new(&metrics);
cores.push(Box::new(Core {
ti... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/multi_thread/worker.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/worker.rs | 281 | 340 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.