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/task/state.rs:8 | return None;
}
let mut next = curr;
next.unset_join_waker();
Some(next)
})
}
pub(super) fn ref_inc(&self) {
use std::process;
use std::sync::atomic::Ordering::Relaxed;
// Using a relaxed ordering is alright here, as knowledge of... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/task/state.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:9 | where
F: FnMut(Snapshot) -> Option<Snapshot>,
{
let mut curr = self.load();
loop {
let next = match f(curr) {
Some(next) => next,
None => return Err(curr),
};
let res = self.val.compare_exchange(curr.0, next.0, AcqRel, Acq... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/task/state.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:10 | }
fn set_running(&mut self) {
self.0 |= RUNNING;
}
fn unset_running(&mut self) {
self.0 &= !RUNNING;
}
pub(super) fn is_cancelled(self) -> bool {
self.0 & CANCELLED == CANCELLED
}
fn set_cancelled(&mut self) {
self.0 |= CANCELLED;
}
fn set_complet... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/task/state.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:11 | self.0 |= JOIN_WAKER;
}
fn unset_join_waker(&mut self) {
self.0 &= !JOIN_WAKER
}
pub(super) fn ref_count(self) -> usize {
(self.0 & REF_COUNT_MASK) >> REF_COUNT_SHIFT
}
fn ref_inc(&mut self) {
assert!(self.0 <= isize::MAX as usize);
self.0 += REF_ONE;
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/task/state.rs | 401 | 446 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:8 | return None;
}
let mut next = curr;
next.unset_join_waker();
Some(next)
})
}
pub(super) fn ref_inc(&self) {
use std::process;
use std::sync::atomic::Ordering::Relaxed;
// Using a relaxed ordering is alright here, as knowledge of... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/task/state.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:10 | }
fn set_running(&mut self) {
self.0 |= RUNNING;
}
fn unset_running(&mut self) {
self.0 &= !RUNNING;
}
pub(super) fn is_cancelled(self) -> bool {
self.0 & CANCELLED == CANCELLED
}
fn set_cancelled(&mut self) {
self.0 |= CANCELLED;
}
fn set_complet... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/task/state.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:11 | self.0 |= JOIN_WAKER;
}
fn unset_join_waker(&mut self) {
self.0 &= !JOIN_WAKER
}
pub(super) fn ref_count(self) -> usize {
(self.0 & REF_COUNT_MASK) >> REF_COUNT_SHIFT
}
fn ref_inc(&mut self) {
assert!(self.0 <= isize::max_value() as usize);
self.0 += REF_ONE;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/task/state.rs | 401 | 446 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:3 | ///
/// If `ref_inc` is set, the reference count is also incremented.
///
/// The `NOTIFIED` bit is always unset.
pub(super) fn transition_to_running(&self, ref_inc: bool) -> UpdateResult {
self.fetch_update(|curr| {
assert!(curr.is_notified());
let mut next = curr;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:4 | let mut next = curr;
next.unset_running();
Some(next)
})
}
/// Transitions the task from `Running` -> `Complete`.
pub(super) fn transition_to_complete(&self) -> Snapshot {
const DELTA: usize = RUNNING | COMPLETE;
let prev = Snapshot(self.val.fetch_xor(DELTA,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:5 | .unwrap()
}
/// Transitions the state to `NOTIFIED`.
///
/// Returns `true` if the task needs to be submitted to the pool for
/// execution
pub(super) fn transition_to_notified(&self) -> bool {
let prev = Snapshot(self.val.fetch_or(NOTIFIED, AcqRel));
prev.will_need_queueing()
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:6 | /// Optimistically tries to swap the state assuming the join handle is
/// __immediately__ dropped on spawn
pub(super) fn drop_join_handle_fast(&self) -> Result<(), ()> {
use std::sync::atomic::Ordering::Relaxed;
// Relaxed is acceptable as if this function is called and succeeds,
// th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:7 | })
}
/// Set the `JOIN_WAKER` bit.
///
/// Returns `Ok` if the bit is set, `Err` otherwise. This operation fails if
/// the task has completed.
pub(super) fn set_join_waker(&self) -> UpdateResult {
self.fetch_update(|curr| {
assert!(curr.is_join_interested());
as... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:8 | })
}
pub(super) fn ref_inc(&self) {
use std::process;
use std::sync::atomic::Ordering::Relaxed;
// Using a relaxed ordering is alright here, as knowledge of the
// original reference prevents other threads from erroneously deleting
// the object.
//
// A... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:9 | fn fetch_update<F>(&self, mut f: F) -> Result<Snapshot, Snapshot>
where
F: FnMut(Snapshot) -> Option<Snapshot>,
{
let mut curr = self.load();
loop {
let next = match f(curr) {
Some(next) => next,
None => return Err(curr),
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:10 | self.0 & RUNNING == RUNNING
}
fn set_running(&mut self) {
self.0 |= RUNNING;
}
fn unset_running(&mut self) {
self.0 &= !RUNNING;
}
pub(super) fn is_cancelled(self) -> bool {
self.0 & CANCELLED == CANCELLED
}
fn set_cancelled(&mut self) {
self.0 |= CANC... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/state.rs:11 | fn set_join_waker(&mut self) {
self.0 |= JOIN_WAKER;
}
fn unset_join_waker(&mut self) {
self.0 &= !JOIN_WAKER
}
pub(super) fn ref_count(self) -> usize {
(self.0 & REF_COUNT_MASK) >> REF_COUNT_SHIFT
}
fn ref_inc(&mut self) {
assert!(self.0 <= isize::max_value() ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/state.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/task/state.rs | 401 | 447 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::context;
use crate::runtime::scheduler::{self, current_thread, Inject};
use crate::task::Id;
use backtrace::BacktraceFrame;
use std::cell::Cell;
use std::collections::VecDeque;
use std::ffi::c_void;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::ptr::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:2 | /// A [`Frame`] in an intrusive, doubly-linked tree of [`Frame`]s.
struct Frame {
/// The location associated with this frame.
inner_addr: *const c_void,
/// The parent frame, if any.
///
/// Tracking parent allows nested `Root` futures to correctly manage their boundaries
parent: Option<NonNul... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:3 | active_frame: Cell::new(None),
trace_leaf_fn: Cell::new(None),
}
}
/// SAFETY: Callers of this function must ensure that trace frames always
/// form a valid linked list.
unsafe fn try_with_current<F, R>(f: F) -> Option<R>
where
F: FnOnce(&Self) -> R,
{
unsaf... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:4 | F: for<'a> FnOnce(&'a mut dyn FnMut(&TraceMeta)) -> R,
{
let mut ret = None;
let inner = |context: &Context| {
if let Some(mut trace_leaf_fn) = context.trace_leaf_fn.replace(None) {
let _restore = defer(move || {
context.trace_leaf_fn.set(Some(trace_l... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | /// Poll::Ready(())
/// })).await;
///
/// assert!(leaf_count > 0);
/// # }
/// ```
pub fn trace_with<FN, FT, R>(f: FN, mut trace_leaf: FT) -> R
where
FN: FnOnce() -> R,
FT: FnMut(&TraceMeta),
{
let trace_leaf_dyn = (&mut trace_leaf) as &mut (dyn FnMut(&TraceMeta) + '_);
// SAFETY: The raw pointer i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | // break the trace frame linked list.
unsafe {
Context::try_with_current(|ctx| {
ctx.trace_leaf_fn.set(old_trace_leaf_fn);
})
};
});
f()
}
impl Trace {
/// Invokes `f`, returning both its result and the collection of backtraces
/// captured at ea... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | }
}
/// If this is a sub-invocation of [`trace_with`], capture a backtrace.
///
/// The captured backtrace will be returned by [`trace_with`].
///
/// Invoking this function does nothing when it is not a sub-invocation
/// [`trace_with`].
// This function is marked `#[inline(never)]` to ensure that it gets a distinct ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | impl<F: FnOnce() -> R, R> Drop for Defer<F, R> {
#[inline(always)]
fn drop(&mut self) {
unsafe {
ManuallyDrop::take(&mut self.0)();
}
}
}
Defer(ManuallyDrop::new(f))
}
impl<T: Future> Future for Root<T> {
type Output = T::Output;
#[inlin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:10 | }
}
/// Trace and poll all tasks of the `current_thread` runtime.
pub(in crate::runtime) fn trace_current_thread(
owned: &OwnedTasks<Arc<current_thread::Handle>>,
local: &mut VecDeque<Notified<Arc<current_thread::Handle>>>,
injection: &Inject<Arc<current_thread::Handle>>,
) -> Vec<(Id, Trace)> {
// cle... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:11 | injection: &Shared<Arc<multi_thread::Handle>>,
) -> Vec<(Id, Trace)> {
let mut dequeued = Vec::new();
// clear the local queue
while let Some(notified) = local.pop() {
dequeued.push(notified);
}
// clear the injection queue
let mut synced = synced.lock()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:12 | }
// We do not poll tasks here, since we hold a lock on `owned` and the
// task may complete and need to remove itself from `owned`. Polling
// such a task here would result in a deadlock.
});
tasks
.into_iter()
.map(|task| {
let local_notified = owned.assert... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/trace/mod.rs | 441 | 477 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | /// Poll::Ready(())
/// })).await;
///
/// assert!(leaf_count > 0);
/// # }
/// ```
pub fn trace_with<FN, FT, R>(f: FN, mut trace_leaf: FT) -> R
where
FN: FnOnce() -> R,
FT: FnMut(&TraceMeta),
{
let trace_leaf_dyn = (&mut trace_leaf) as &mut (dyn FnMut(&TraceMeta) + '_);
// SAFETY: The raw pointer i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 36d12d2686a64b9146c674e02e3cf81d8f87163d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/36d12d2686a64b9146c674e02e3cf81d8f87163d/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | // break the trace frame linked list.
unsafe {
Context::try_with_current(|ctx| {
ctx.trace_leaf_fn.set(old_trace_leaf_fn);
})
};
});
f()
}
impl Trace {
/// Invokes `f`, returning both its result and the collection of backtraces
/// captured at ea... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 36d12d2686a64b9146c674e02e3cf81d8f87163d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/36d12d2686a64b9146c674e02e3cf81d8f87163d/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | /// If this is a sub-invocation of [`Trace::capture`], capture a backtrace.
///
/// The captured backtrace will be returned by [`Trace::capture`].
///
/// Invoking this function does nothing when it is not a sub-invocation
/// [`Trace::capture`].
// This function is marked `#[inline(never)]` to ensure that it gets a di... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 36d12d2686a64b9146c674e02e3cf81d8f87163d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/36d12d2686a64b9146c674e02e3cf81d8f87163d/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | impl fmt::Display for Trace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Tree::from_trace(self.clone()).fmt(f)
}
}
fn defer<F: FnOnce() -> R, R>(f: F) -> impl Drop {
use std::mem::ManuallyDrop;
struct Defer<F: FnOnce() -> R, R>(ManuallyDrop<F>);
impl<F: FnOnce() -> R, R> D... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 36d12d2686a64b9146c674e02e3cf81d8f87163d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/36d12d2686a64b9146c674e02e3cf81d8f87163d/tokio/src/runtime/task/trace/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:10 | let _restore = defer(|| {
Context::with_current_frame(|current| {
current.set(frame.parent);
});
});
let this = self.project();
this.future.poll(cx)
}
}
}
/// Trace and poll all tasks of the `current_thread` runtime.
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 36d12d2686a64b9146c674e02e3cf81d8f87163d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/36d12d2686a64b9146c674e02e3cf81d8f87163d/tokio/src/runtime/task/trace/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:11 | /// Trace and poll all tasks of the `current_thread` runtime.
///
/// ## Safety
///
/// Must be called with the same `synced` that `injection` was created with.
pub(in crate::runtime) unsafe fn trace_multi_thread(
owned: &OwnedTasks<Arc<multi_thread::Handle>>,
local: &mut multi_threa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 36d12d2686a64b9146c674e02e3cf81d8f87163d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/36d12d2686a64b9146c674e02e3cf81d8f87163d/tokio/src/runtime/task/trace/mod.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:12 | fn trace_owned<S: Schedule>(owned: &OwnedTasks<S>, dequeued: Vec<Notified<S>>) -> Vec<(Id, Trace)> {
let mut tasks = dequeued;
// Notify and trace all un-notified tasks. The dequeued tasks are already
// notified and so do not need to be re-notified.
owned.for_each(|task| {
// Notify the task (a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 36d12d2686a64b9146c674e02e3cf81d8f87163d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/36d12d2686a64b9146c674e02e3cf81d8f87163d/tokio/src/runtime/task/trace/mod.rs | 441 | 466 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::context;
use crate::runtime::scheduler::{self, current_thread, Inject};
use crate::task::Id;
use backtrace::BacktraceFrame;
use std::cell::Cell;
use std::collections::VecDeque;
use std::ffi::c_void;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::ptr::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:2 | struct Frame {
/// The location associated with this frame.
inner_addr: *const c_void,
/// The parent frame, if any.
///
/// Tracking parent allows nested `Root` futures to correctly manage their boundaries
parent: Option<NonNull<Frame>>,
}
/// An tree execution trace.
///
/// Traces are captu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:3 | trace_leaf_fn: Cell::new(None),
}
}
/// SAFETY: Callers of this function must ensure that trace frames always
/// form a valid linked list.
unsafe fn try_with_current<F, R>(f: F) -> Option<R>
where
F: FnOnce(&Self) -> R,
{
unsafe { crate::runtime::context::with_trace(f) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:5 | ///
/// ```
/// use std::future::Future;
/// use std::task::Poll;
/// use tokio::runtime::dump::{trace_with, Trace, TraceMeta};
///
/// // Thread-local storage for the custom trace function.
/// std::thread_local! {
/// static LEAF_COUNT: std::cell::Cell<u32> = const { std::cell::Cell::new(0) };
/// }
///
/// fn my... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | // even if the trace_leaf function panics
let _restore = defer(move || {
if let Some(previous) = previous {
Context::try_with_current_trace_leaf_fn(|current| current.set(previous));
}
});
f()
}
impl Trace {
/// Invokes `f`, returning both its result and the collection of ba... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | /// If this is a sub-invocation of [`Trace::capture`], capture a backtrace.
///
/// The captured backtrace will be returned by [`Trace::capture`].
///
/// Invoking this function does nothing when it is not a sub-invocation
/// [`Trace::capture`].
// This function is marked `#[inline(never)]` to ensure that it gets a di... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | }
}
fn defer<F: FnOnce() -> R, R>(f: F) -> impl Drop {
use std::mem::ManuallyDrop;
struct Defer<F: FnOnce() -> R, R>(ManuallyDrop<F>);
impl<F: FnOnce() -> R, R> Drop for Defer<F, R> {
#[inline(always)]
fn drop(&mut self) {
unsafe {
ManuallyDrop::take(&mut self.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | current.set(frame.parent);
});
});
let this = self.project();
this.future.poll(cx)
}
}
}
/// Trace and poll all tasks of the `current_thread` runtime.
pub(in crate::runtime) fn trace_current_thread(
owned: &OwnedTasks<Arc<current_thread::Handle>>,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:10 | /// ## Safety
///
/// Must be called with the same `synced` that `injection` was created with.
pub(in crate::runtime) unsafe fn trace_multi_thread(
owned: &OwnedTasks<Arc<multi_thread::Handle>>,
local: &mut multi_thread::queue::Local<Arc<multi_thread::Handle>>,
synced: &Mutex<Synced>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:11 | // notified and so do not need to be re-notified.
owned.for_each(|task| {
// Notify the task (and thus make it poll-able) and stash it. This fails
// if the task is already notified. In these cases, we skip tracing the
// task.
if let Some(notified) = task.notify_for_tracing() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bbdba7101de6ce5329d84021ce669f185cc430b3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bbdba7101de6ce5329d84021ce669f185cc430b3/tokio/src/runtime/task/trace/mod.rs | 401 | 423 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::context;
use crate::runtime::scheduler::{self, current_thread, Inject};
use crate::task::Id;
use backtrace::BacktraceFrame;
use std::cell::Cell;
use std::collections::VecDeque;
use std::ffi::c_void;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::ptr::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:2 | /// The parent frame, if any.
parent: Option<NonNull<Frame>>,
}
/// An tree execution trace.
///
/// Traces are captured with [`Trace::capture`], rooted with [`Trace::root`]
/// and leaved with [`trace_leaf`].
#[derive(Clone, Debug)]
pub(crate) struct Trace {
// The linear backtraces that comprise this trace. ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:3 | unsafe fn try_with_current<F, R>(f: F) -> Option<R>
where
F: FnOnce(&Self) -> R,
{
unsafe { crate::runtime::context::with_trace(f) }
}
/// SAFETY: Callers of this function must ensure that trace frames always
/// form a valid linked list.
unsafe fn with_current_frame<F, R>(f: F)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:4 | impl Trace {
/// Invokes `f`, returning both its result and the collection of backtraces
/// captured at each sub-invocation of [`trace_leaf`].
#[inline(never)]
pub(crate) fn capture<F, R>(f: F) -> (R, Trace)
where
F: FnOnce() -> R,
{
let collector = Trace { backtraces: vec![] };... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:5 | #[inline(never)]
pub(crate) fn trace_leaf(cx: &mut task::Context<'_>) -> Poll<()> {
// Safety: We don't manipulate the current context's active frame.
let did_trace = unsafe {
Context::try_with_current(|context_cell| {
if let Some(mut collector) = context_cell.collector.take() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | // Use the same logic that `yield_now` uses to send out wakeups after
// the task yields.
context::with_scheduler(|scheduler| {
if let Some(scheduler) = scheduler {
match scheduler {
scheduler::Context::CurrentThread(s) => s.defer.defer(cx.waker()),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | impl<T: Future> Future for Root<T> {
type Output = T::Output;
#[inline(never)]
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// SAFETY: The context's current frame is restored to its original state
// before `frame` is dropped.
unsafe {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | while let Some(task) = local.pop_back() {
dequeued.push(task);
}
while let Some(task) = injection.pop() {
dequeued.push(task);
}
// precondition: We have drained the tasks from the injection queue.
trace_owned(owned, dequeued)
}
cfg_rt_multi_thread! {
use crate::loom::sync::Mu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | while let Some(notified) = unsafe { injection.pop(&mut synced.inject) } {
dequeued.push(notified);
}
drop(synced);
// precondition: we have drained the tasks from the local and injection
// queues.
trace_owned(owned, dequeued)
}
}
/// Trace the `OwnedTasks`.
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/runtime/task/trace/mod.rs | 321 | 364 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:2 | /// The parent frame, if any.
parent: Option<NonNull<Frame>>,
}
/// An tree execution trace.
///
/// Traces are captured with [`Trace::capture`], rooted with [`Trace::root`]
/// and leaved with [`trace_leaf`].
#[derive(Clone, Debug)]
pub(crate) struct Trace {
// The linear backtraces that comprise this trace. ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 159a3b2c8587cd12ad54eb16489dad6eb674d4ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159a3b2c8587cd12ad54eb16489dad6eb674d4ca/tokio/src/runtime/task/trace/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:3 | unsafe fn try_with_current<F, R>(f: F) -> Option<R>
where
F: FnOnce(&Self) -> R,
{
crate::runtime::context::with_trace(f)
}
unsafe fn with_current_frame<F, R>(f: F) -> R
where
F: FnOnce(&Cell<Option<NonNull<Frame>>>) -> R,
{
Self::try_with_current(|context| f(&co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 159a3b2c8587cd12ad54eb16489dad6eb674d4ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159a3b2c8587cd12ad54eb16489dad6eb674d4ca/tokio/src/runtime/task/trace/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:4 | pub(crate) fn capture<F, R>(f: F) -> (R, Trace)
where
F: FnOnce() -> R,
{
let collector = Trace { backtraces: vec![] };
let previous = Context::with_current_collector(|current| current.replace(Some(collector)));
let result = f();
let collector =
Context::wi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 159a3b2c8587cd12ad54eb16489dad6eb674d4ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159a3b2c8587cd12ad54eb16489dad6eb674d4ca/tokio/src/runtime/task/trace/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:5 | Context::try_with_current(|context_cell| {
if let Some(mut collector) = context_cell.collector.take() {
let mut frames = vec![];
let mut above_leaf = false;
if let Some(active_frame) = context_cell.active_frame.get() {
let active_frame = a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 159a3b2c8587cd12ad54eb16489dad6eb674d4ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159a3b2c8587cd12ad54eb16489dad6eb674d4ca/tokio/src/runtime/task/trace/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | match scheduler {
scheduler::Context::CurrentThread(s) => s.defer.defer(cx.waker()),
#[cfg(feature = "rt-multi-thread")]
scheduler::Context::MultiThread(s) => s.defer.defer(cx.waker()),
}
}
});
Poll::Pending
} e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 159a3b2c8587cd12ad54eb16489dad6eb674d4ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159a3b2c8587cd12ad54eb16489dad6eb674d4ca/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | #[inline(never)]
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// SAFETY: The context's current frame is restored to its original state
// before `frame` is dropped.
unsafe {
let mut frame = Frame {
inner_addr: Self::poll as *co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 159a3b2c8587cd12ad54eb16489dad6eb674d4ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159a3b2c8587cd12ad54eb16489dad6eb674d4ca/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | while let Some(task) = injection.pop() {
dequeued.push(task);
}
// precondition: We have drained the tasks from the injection queue.
trace_owned(owned, dequeued)
}
cfg_rt_multi_thread! {
use crate::loom::sync::Mutex;
use crate::runtime::scheduler::multi_thread;
use crate::runtime::sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 159a3b2c8587cd12ad54eb16489dad6eb674d4ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159a3b2c8587cd12ad54eb16489dad6eb674d4ca/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | // precondition: we have drained the tasks from the local and injection
// queues.
trace_owned(owned, dequeued)
}
}
/// Trace the `OwnedTasks`.
///
/// # Preconditions
///
/// This helper presumes exclusive access to each task. The tasks must not exist
/// in any other queue.
fn trace_owned<S: Sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 159a3b2c8587cd12ad54eb16489dad6eb674d4ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159a3b2c8587cd12ad54eb16489dad6eb674d4ca/tokio/src/runtime/task/trace/mod.rs | 321 | 359 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:5 | Context::try_with_current(|context_cell| {
if let Some(mut collector) = context_cell.collector.take() {
let mut frames = vec![];
let mut above_leaf = false;
if let Some(active_frame) = context_cell.active_frame.get() {
let active_frame = a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 2671ffb55b8f2464c0f1c3c7d99ee70118108755 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2671ffb55b8f2464c0f1c3c7d99ee70118108755/tokio/src/runtime/task/trace/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | match scheduler {
scheduler::Context::CurrentThread(s) => s.defer.defer(cx.waker()),
#[cfg(feature = "rt-multi-thread")]
scheduler::Context::MultiThread(s) => s.defer.defer(cx.waker()),
#[cfg(all(tokio_unstable, feature = "rt-multi-thread")... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 2671ffb55b8f2464c0f1c3c7d99ee70118108755 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2671ffb55b8f2464c0f1c3c7d99ee70118108755/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | type Output = T::Output;
#[inline(never)]
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// SAFETY: The context's current frame is restored to its original state
// before `frame` is dropped.
unsafe {
let mut frame = Frame {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 2671ffb55b8f2464c0f1c3c7d99ee70118108755 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2671ffb55b8f2464c0f1c3c7d99ee70118108755/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | dequeued.push(task);
}
while let Some(task) = injection.pop() {
dequeued.push(task);
}
// precondition: We have drained the tasks from the injection queue.
trace_owned(owned, dequeued)
}
cfg_rt_multi_thread! {
use crate::loom::sync::Mutex;
use crate::runtime::scheduler::multi_thre... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 2671ffb55b8f2464c0f1c3c7d99ee70118108755 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2671ffb55b8f2464c0f1c3c7d99ee70118108755/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | drop(synced);
// precondition: we have drained the tasks from the local and injection
// queues.
trace_owned(owned, dequeued)
}
}
/// Trace the `OwnedTasks`.
///
/// # Preconditions
///
/// This helper presumes exclusive access to each task. The tasks must not exist
/// in any other queue.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 2671ffb55b8f2464c0f1c3c7d99ee70118108755 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2671ffb55b8f2464c0f1c3c7d99ee70118108755/tokio/src/runtime/task/trace/mod.rs | 321 | 361 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::context;
use crate::runtime::scheduler::{self, current_thread, Inject};
use crate::task::Id;
use backtrace::BacktraceFrame;
use std::cell::Cell;
use std::collections::VecDeque;
use std::ffi::c_void;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::ptr::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa/tokio/src/runtime/task/trace/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:2 | /// The parent frame, if any.
parent: Option<NonNull<Frame>>,
}
/// An tree execution trace.
///
/// Traces are captured with [`Trace::capture`], rooted with [`Trace::root`]
/// and leaved with [`trace_leaf`].
#[derive(Clone, Debug)]
pub(crate) struct Trace {
// The linear backtraces that comprise this trace. ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa/tokio/src/runtime/task/trace/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:3 | where
F: FnOnce(&Self) -> R,
{
crate::runtime::context::with_trace(f)
}
unsafe fn with_current_frame<F, R>(f: F) -> R
where
F: FnOnce(&Cell<Option<NonNull<Frame>>>) -> R,
{
Self::try_with_current(|context| f(&context.active_frame)).expect(FAIL_NO_THREAD_LOCAL)
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa/tokio/src/runtime/task/trace/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:4 | where
F: FnOnce() -> R,
{
let collector = Trace { backtraces: vec![] };
let previous = Context::with_current_collector(|current| current.replace(Some(collector)));
let result = f();
let collector =
Context::with_current_collector(|current| current.replace(previ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa/tokio/src/runtime/task/trace/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:5 | if let Some(mut collector) = context_cell.collector.take() {
let mut frames = vec![];
let mut above_leaf = false;
if let Some(active_frame) = context_cell.active_frame.get() {
let active_frame = active_frame.as_ref();
backtrace::t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa/tokio/src/runtime/task/trace/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | scheduler::Context::CurrentThread(s) => s.defer.defer(cx.waker()),
#[cfg(feature = "rt-multi-thread")]
scheduler::Context::MultiThread(s) => s.defer.defer(cx.waker()),
#[cfg(all(tokio_unstable, feature = "rt-multi-thread"))]
scheduler::Cont... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | #[inline(never)]
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// SAFETY: The context's current frame is restored to its original state
// before `frame` is dropped.
unsafe {
let mut frame = Frame {
inner_addr: Self::poll as *co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | }
while let Some(task) = injection.pop() {
dequeued.push(task);
}
// precondition: We have drained the tasks from the injection queue.
trace_owned(owned, dequeued)
}
cfg_rt_multi_thread! {
use crate::loom::sync::Mutex;
use crate::runtime::scheduler::multi_thread;
use crate::runtim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bfa8cadaa078dd1d53f1f3b71f9a782aa6092aaa/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::context;
use crate::runtime::scheduler::{self, current_thread, Inject};
use crate::task::Id;
use backtrace::BacktraceFrame;
use std::cell::Cell;
use std::collections::VecDeque;
use std::ffi::c_void;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::ptr::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 48e07a6d1011825d3c8d90fb6351ad68ea479dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/48e07a6d1011825d3c8d90fb6351ad68ea479dfc/tokio/src/runtime/task/trace/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:4 | where
F: FnOnce() -> R,
{
let collector = Trace { backtraces: vec![] };
let previous = Context::with_current_collector(|current| current.replace(Some(collector)));
let result = f();
let collector =
Context::with_current_collector(|current| current.replace(previ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 9ed595767d01c400955122d276b34ab52b3a6aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9ed595767d01c400955122d276b34ab52b3a6aab/tokio/src/runtime/task/trace/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:5 | if let Some(active_frame) = context_cell.active_frame.get() {
let active_frame = active_frame.as_ref();
backtrace::trace(|frame| {
let below_root = !ptr::eq(frame.symbol_address(), active_frame.inner_addr);
// only capture frames ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 9ed595767d01c400955122d276b34ab52b3a6aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9ed595767d01c400955122d276b34ab52b3a6aab/tokio/src/runtime/task/trace/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | scheduler::Context::MultiThreadAlt(_) => unimplemented!(),
}
}
});
Poll::Pending
} else {
Poll::Ready(())
}
}
impl fmt::Display for Trace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Tree::from_trace(self.clone()).fmt(f)
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 9ed595767d01c400955122d276b34ab52b3a6aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9ed595767d01c400955122d276b34ab52b3a6aab/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | // before `frame` is dropped.
unsafe {
let mut frame = Frame {
inner_addr: Self::poll as *const c_void,
parent: None,
};
Context::with_current_frame(|current| {
frame.parent = current.take();
current.set(Some(No... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 9ed595767d01c400955122d276b34ab52b3a6aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9ed595767d01c400955122d276b34ab52b3a6aab/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | }
// precondition: We have drained the tasks from the injection queue.
trace_owned(owned, dequeued)
}
cfg_rt_multi_thread! {
use crate::loom::sync::Mutex;
use crate::runtime::scheduler::multi_thread;
use crate::runtime::scheduler::multi_thread::Synced;
use crate::runtime::scheduler::inject::Sh... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 9ed595767d01c400955122d276b34ab52b3a6aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9ed595767d01c400955122d276b34ab52b3a6aab/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | trace_owned(owned, dequeued)
}
}
/// Trace the `OwnedTasks`.
///
/// # Preconditions
///
/// This helper presumes exclusive access to each task. The tasks must not exist
/// in any other queue.
fn trace_owned<S: Schedule>(owned: &OwnedTasks<S>, dequeued: Vec<Notified<S>>) -> Vec<(Id, Trace)> {
let mut tasks = ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 9ed595767d01c400955122d276b34ab52b3a6aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9ed595767d01c400955122d276b34ab52b3a6aab/tokio/src/runtime/task/trace/mod.rs | 321 | 356 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:5 | if let Some(active_frame) = context_cell.active_frame.get() {
let active_frame = active_frame.as_ref();
backtrace::trace(|frame| {
let below_root = !ptr::eq(frame.symbol_address(), active_frame.inner_addr);
// only capture frames ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 10c9eeb6c2af85961044b7cbb16a5a2d2e97287d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/10c9eeb6c2af85961044b7cbb16a5a2d2e97287d/tokio/src/runtime/task/trace/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | tokio_unstable,
feature = "rt-multi-thread",
not(target_os = "wasi")
))]
scheduler::Context::MultiThreadAlt(_) => unimplemented!(),
}
}
});
Poll::Pending
} else {
Poll::Ready(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 10c9eeb6c2af85961044b7cbb16a5a2d2e97287d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/10c9eeb6c2af85961044b7cbb16a5a2d2e97287d/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::context;
use crate::runtime::scheduler::{self, current_thread, Inject};
use backtrace::BacktraceFrame;
use std::cell::Cell;
use std::collections::VecDeque;
use std::ffi::c_void;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::ptr::{self, NonNull};
use ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:2 | parent: Option<NonNull<Frame>>,
}
/// An tree execution trace.
///
/// Traces are captured with [`Trace::capture`], rooted with [`Trace::root`]
/// and leaved with [`trace_leaf`].
#[derive(Clone, Debug)]
pub(crate) struct Trace {
// The linear backtraces that comprise this trace. These linear traces can
// be ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:3 | F: FnOnce(&Self) -> R,
{
crate::runtime::context::with_trace(f)
}
unsafe fn with_current_frame<F, R>(f: F) -> R
where
F: FnOnce(&Cell<Option<NonNull<Frame>>>) -> R,
{
Self::try_with_current(|context| f(&context.active_frame)).expect(FAIL_NO_THREAD_LOCAL)
}
fn with_c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:4 | F: FnOnce() -> R,
{
let collector = Trace { backtraces: vec![] };
let previous = Context::with_current_collector(|current| current.replace(Some(collector)));
let result = f();
let collector =
Context::with_current_collector(|current| current.replace(previous)).unwrap()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:5 | let active_frame = active_frame.as_ref();
backtrace::trace(|frame| {
let below_root = !ptr::eq(frame.symbol_address(), active_frame.inner_addr);
// only capture frames above `Trace::leaf` and below
// `Trace::root`.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:6 | feature = "rt-multi-thread",
not(target_os = "wasi")
))]
scheduler::Context::MultiThreadAlt(_) => unimplemented!(),
}
}
});
Poll::Pending
} else {
Poll::Ready(())
}
}
impl fmt::Display for Trace... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | #[inline(never)]
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// SAFETY: The context's current frame is restored to its original state
// before `frame` is dropped.
unsafe {
let mut frame = Frame {
inner_addr: Self::poll as *co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | while let Some(task) = injection.pop() {
dequeued.push(task);
}
// precondition: We have drained the tasks from the injection queue.
trace_owned(owned, dequeued)
}
cfg_rt_multi_thread! {
use crate::loom::sync::Mutex;
use crate::runtime::scheduler::multi_thread;
use crate::runtime::sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | // precondition: we have drained the tasks from the local and injection
// queues.
trace_owned(owned, dequeued)
}
}
/// Trace the `OwnedTasks`.
///
/// # Preconditions
///
/// This helper presumes exclusive access to each task. The tasks must not exist
/// in any other queue.
fn trace_owned<S: Sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/trace/mod.rs | 321 | 358 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | #[inline(never)]
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// SAFETY: The context's current frame is restored to its original state
// before `frame` is dropped.
unsafe {
let mut frame = Frame {
inner_addr: Self::poll as *co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | d561b5850ad95f08505630ecae05f7a8e1d09eea | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d561b5850ad95f08505630ecae05f7a8e1d09eea/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | while let Some(task) = injection.pop() {
dequeued.push(task);
}
// precondition: We have drained the tasks from the injection queue.
trace_owned(owned, dequeued)
}
cfg_rt_multi_thread! {
use crate::loom::sync::Mutex;
use crate::runtime::scheduler::multi_thread;
use crate::runtime::sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | d561b5850ad95f08505630ecae05f7a8e1d09eea | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d561b5850ad95f08505630ecae05f7a8e1d09eea/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:7 | #[inline(never)]
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// SAFETY: The context's current frame is restored to its original state
// before `frame` is dropped.
unsafe {
let mut frame = Frame {
inner_addr: Self::poll as *co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 2bd43765d99e7caaee626f6804ef9f56cc06aefd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2bd43765d99e7caaee626f6804ef9f56cc06aefd/tokio/src/runtime/task/trace/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:8 | // precondition: We have drained the tasks from the injection queue.
trace_owned(owned)
}
cfg_rt_multi_thread! {
use crate::loom::sync::Mutex;
use crate::runtime::scheduler::multi_thread;
use crate::runtime::scheduler::multi_thread::Synced;
use crate::runtime::scheduler::inject::Shared;
/// Tr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 2bd43765d99e7caaee626f6804ef9f56cc06aefd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2bd43765d99e7caaee626f6804ef9f56cc06aefd/tokio/src/runtime/task/trace/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:9 | /// Trace the `OwnedTasks`.
///
/// # Preconditions
///
/// This helper presumes exclusive access to each task. The tasks must not exist
/// in any other queue.
fn trace_owned<S: Schedule>(owned: &OwnedTasks<S>) -> Vec<Trace> {
// notify each task
let mut tasks = vec![];
owned.for_each(|task| {
// n... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | 2bd43765d99e7caaee626f6804ef9f56cc06aefd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2bd43765d99e7caaee626f6804ef9f56cc06aefd/tokio/src/runtime/task/trace/mod.rs | 321 | 345 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::context;
use crate::runtime::scheduler::{self, current_thread, Inject};
use backtrace::BacktraceFrame;
use std::cell::Cell;
use std::collections::VecDeque;
use std::ffi::c_void;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::ptr::{self, NonNull};
use ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/runtime/task/trace/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:3 | F: FnOnce(&Self) -> R,
{
crate::runtime::context::with_trace(f)
}
unsafe fn with_current_frame<F, R>(f: F) -> R
where
F: FnOnce(&Cell<Option<NonNull<Frame>>>) -> R,
{
Self::try_with_current(|context| f(&context.active_frame)).expect(FAIL_NO_THREAD_LOCAL)
}
fn with_c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/runtime/task/trace/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/trace/mod.rs:4 | (result, collector)
}
/// The root of a trace.
#[inline(never)]
pub(crate) fn root<F>(future: F) -> Root<F> {
Root { future }
}
}
/// If this is a sub-invocation of [`Trace::capture`], capture a backtrace.
///
/// The captured backtrace will be returned by [`Trace::capture`].
///
/// Invok... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/trace/mod.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/runtime/task/trace/mod.rs | 121 | 180 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.