repo stringclasses 7
values | lang stringclasses 2
values | aspect stringclasses 7
values | file stringlengths 5 48 | content stringlengths 283 144k |
|---|---|---|---|---|
tokio | rust | async_runtime | op.rs | use crate::io::blocking::Buf;
use crate::io::uring::open::Open;
use crate::io::uring::read::Read;
use crate::io::uring::rename::Rename;
use crate::io::uring::utils::ArcFd;
use crate::io::uring::write::Write;
use crate::runtime::io::RegisterResult;
use crate::runtime::Handle;
#[cfg(
// libc::statx is only supporte... |
tokio | rust | async_runtime | registration_queue.rs | use super::{EntryHandle, RegistrationQueueEntry};
use crate::util::linked_list::LinkedList;
/// A queue of entries that need to be registered in the timer wheel.
#[derive(Debug)]
pub(crate) struct RegistrationQueue {
list: LinkedList<RegistrationQueueEntry>,
}
impl Drop for RegistrationQueue {
fn drop(&mut se... |
tokio | rust | async_runtime | timer.rs | use super::{EntryHandle, TempLocalContext};
use crate::runtime::scheduler;
use std::pin::Pin;
use std::task::{Context, Poll};
#[cfg(any(feature = "rt", feature = "rt-multi-thread"))]
use crate::util::error::RUNTIME_SHUTTING_DOWN_ERROR;
pub(crate) struct Timer {
/// The entry in the timing wheel.
entry: Entry... |
tokio | rust | async_runtime | mod.rs | pub(crate) mod context;
pub(super) use context::{LocalContext, TempLocalContext};
pub(crate) mod cancellation_queue;
mod entry;
pub(crate) use entry::Handle as EntryHandle;
use entry::{CancellationQueueEntry, Entry, RegistrationQueueEntry, WakeQueueEntry};
mod registration_queue;
pub(crate) use registration_queue::R... |
tokio | rust | async_runtime | cancellation_queue.rs | use super::{CancellationQueueEntry, EntryHandle};
use crate::loom::sync::{Arc, Mutex};
use crate::util::linked_list::LinkedList;
#[derive(Debug, Default)]
struct Inner {
list: LinkedList<CancellationQueueEntry>,
}
impl Drop for Inner {
fn drop(&mut self) {
// consume all entries
while let Some... |
tokio | rust | async_runtime | entry.rs | use super::cancellation_queue::Sender;
use crate::loom::sync::{Arc, Mutex};
use crate::util::linked_list;
use std::marker::PhantomPinned;
use std::ptr::NonNull;
use std::task::{Context, Poll, Waker};
#[derive(Debug, Default)]
struct State {
cancelled: bool,
woken_up: bool,
waker: Option<Waker>,
cancel... |
tokio | rust | async_runtime | wake_queue.rs | use super::{EntryHandle, WakeQueueEntry};
use crate::util::linked_list::LinkedList;
/// A queue of entries that need to be woken up.
#[derive(Debug)]
pub(crate) struct WakeQueue {
list: LinkedList<WakeQueueEntry>,
}
impl Drop for WakeQueue {
fn drop(&mut self) {
// drain all entries without waking the... |
tokio | rust | async_runtime | context.rs | use super::{cancellation_queue, RegistrationQueue, Wheel};
/// Local context for the time driver, used when the runtime wants to
/// fire/cancel timers.
pub(crate) struct LocalContext {
pub(crate) wheel: Wheel,
pub(crate) registration_queue: RegistrationQueue,
pub(crate) canc_tx: cancellation_queue::Sender... |
tokio | rust | async_runtime | mod.rs | mod level;
pub(crate) use self::level::Expiration;
use self::level::Level;
use super::cancellation_queue::Sender;
use super::{Entry, EntryHandle, WakeQueue};
use crate::util::linked_list::LinkedList;
/// Hashed timing wheel implementation.
///
/// See [`Driver`] documentation for some implementation notes.
///
/// [... |
tokio | rust | async_runtime | level.rs | use crate::util::linked_list::LinkedList;
use super::{Entry, EntryHandle};
use std::ptr::NonNull;
use std::{array, fmt};
/// Wheel for a single level in the timer. This wheel contains 64 slots.
pub(crate) struct Level {
level: usize,
/// Bit field tracking which slots currently contain entries.
///
/... |
tokio | rust | async_runtime | scheduled_io.rs | use crate::io::interest::Interest;
use crate::io::ready::Ready;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::runtime::io::{Direction, ReadyEvent, Tick};
use crate::util::bit;
use crate::util::linked_list::{self, LinkedList};
use crate::util::WakeList;
use std::cell::UnsafeCell;
... |
tokio | rust | async_runtime | registration.rs | #![cfg_attr(not(feature = "net"), allow(dead_code))]
use crate::io::interest::Interest;
use crate::runtime::io::{Direction, Handle, ReadyEvent, ScheduledIo};
use crate::runtime::scheduler;
use crate::loom::sync::Arc;
use mio::event::Source;
use std::io;
use std::task::{ready, Context, Poll};
cfg_io_driver! {
///... |
tokio | rust | async_runtime | metrics.rs | cfg_not_rt_and_metrics_and_net! {
#[derive(Default)]
pub(crate) struct IoDriverMetrics {}
impl IoDriverMetrics {
pub(crate) fn incr_fd_count(&self) {}
pub(crate) fn dec_fd_count(&self) {}
pub(crate) fn incr_ready_count_by(&self, _amt: u64) {}
}
}
cfg_net! {
cfg_rt! {
... |
tokio | rust | async_runtime | mod.rs | #![cfg_attr(
not(all(feature = "rt", feature = "net", feature = "io-uring", tokio_unstable)),
allow(dead_code)
)]
mod driver;
use driver::{Direction, Tick};
pub(crate) use driver::{Driver, Handle, ReadyEvent};
cfg_io_uring! {
pub(crate) use driver::RegisterResult;
}
mod registration;
pub(crate) use registr... |
tokio | rust | async_runtime | driver.rs | // Signal handling
cfg_signal_internal_and_unix! {
mod signal;
}
cfg_io_uring! {
mod uring;
use uring::UringContext;
pub(crate) use uring::RegisterResult;
use crate::sync::OnceCell;
}
use crate::io::interest::Interest;
use crate::io::ready::Ready;
use crate::loom::sync::Mutex;
use crate::runtime::d... |
tokio | rust | async_runtime | registration_set.rs | use crate::loom::sync::atomic::AtomicUsize;
use crate::runtime::io::ScheduledIo;
use crate::util::linked_list::{self, LinkedList};
use crate::loom::sync::Arc;
use std::io;
use std::ptr::NonNull;
use std::sync::atomic::Ordering::{Acquire, Release};
// Kind of arbitrary, but buffering 16 `ScheduledIo`s doesn't seem lik... |
tokio | rust | async_runtime | uring.rs | use io_uring::{squeue::Entry, IoUring, Probe};
use mio::unix::SourceFd;
use slab::Slab;
use crate::runtime::driver::op::CancelData;
use crate::runtime::driver::op::CqeResult;
use crate::runtime::driver::op::{Cancellable, Lifecycle};
use crate::{io::Interest, loom::sync::Mutex};
use super::{Handle, TOKEN_WAKEUP};
use... |
tokio | rust | async_runtime | signal.rs | use super::{Driver, Handle, TOKEN_SIGNAL};
use std::io;
impl Handle {
pub(crate) fn register_signal_receiver(
&self,
receiver: &mut mio::net::UnixStream,
) -> io::Result<()> {
self.registry
.register(receiver, TOKEN_SIGNAL, mio::Interest::READABLE)?;
Ok(())
}
}
... |
tokio | rust | async_runtime | loom_oneshot.rs | use crate::loom::sync::{Arc, Mutex};
use loom::sync::Notify;
pub(crate) fn channel<T>() -> (Sender<T>, Receiver<T>) {
let inner = Arc::new(Inner {
notify: Notify::new(),
value: Mutex::new(None),
});
let tx = Sender {
inner: inner.clone(),
};
let rx = Receiver { inner };
... |
tokio | rust | async_runtime | loom_multi_thread.rs | mod queue;
mod shutdown;
mod yield_now;
/// Full runtime loom tests. These are heavy tests and take significant time to
/// run on CI.
///
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
///
/// In order to speed up the C
use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::{se... |
tokio | rust | async_runtime | loom_join_set.rs | use crate::runtime::Builder;
use crate::task::JoinSet;
#[test]
fn test_join_set() {
loom::model(|| {
let rt = Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
let mut set = JoinSet::new();
rt.block_on(async {
assert_eq!(set.... |
tokio | rust | async_runtime | queue.rs | use crate::runtime::scheduler::multi_thread::{queue, Stats};
use std::cell::RefCell;
use std::thread;
use std::time::Duration;
#[allow(unused)]
macro_rules! assert_metrics {
($stats:ident, $field:ident == $v:expr) => {
#[cfg(target_has_atomic = "64")]
{
use crate::runtime::WorkerMetric... |
tokio | rust | async_runtime | task.rs | use crate::runtime::task::{
self, unowned, Id, JoinHandle, OwnedTasks, Schedule, SpawnLocation, Task,
TaskHarnessScheduleHooks,
};
use crate::runtime::tests::NoopSchedule;
use std::collections::VecDeque;
use std::future::Future;
#[cfg(tokio_unstable)]
use std::panic::Location;
use std::sync::atomic::{AtomicBoo... |
tokio | rust | async_runtime | loom_current_thread.rs | mod yield_now;
use crate::loom::sync::atomic::{AtomicUsize, Ordering};
use crate::loom::sync::Arc;
use crate::loom::thread;
use crate::runtime::{Builder, Runtime};
use crate::sync::oneshot::{self, Receiver};
use crate::task;
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::Ordering::{Acquire, Release... |
tokio | rust | async_runtime | mod.rs | // Enable dead_code / unreachable_pub here. It has been disabled in lib.rs for
// other code when running loom tests.
#![cfg_attr(loom, warn(dead_code, unreachable_pub))]
use self::noop_scheduler::NoopSchedule;
use self::unowned_wrapper::unowned;
mod noop_scheduler {
use crate::runtime::task::{self, Task, TaskHar... |
tokio | rust | async_runtime | task_combinations.rs | use std::fmt;
use std::future::Future;
use std::panic;
use std::pin::Pin;
use std::task::{Context, Poll};
use crate::runtime::task::AbortHandle;
use crate::runtime::Builder;
use crate::sync::oneshot;
use crate::task::JoinHandle;
use futures::future::FutureExt;
// Enums for each option in the combinations being teste... |
tokio | rust | async_runtime | loom_blocking.rs | use crate::runtime::{self, Runtime};
use std::sync::Arc;
use std::time::Duration;
#[test]
fn blocking_shutdown() {
loom::model(|| {
let v = Arc::new(());
let rt = mk_runtime(1);
{
let _enter = rt.enter();
for _ in 0..2 {
let v = v.clone();
... |
tokio | rust | async_runtime | loom_local.rs | use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::Builder;
use crate::task::LocalSet;
use std::task::Poll;
/// Waking a runtime will attempt to push a task into a queue of notifications
/// in the runtime, however the tasks in such a queue usually have a reference
/// to the runtime itself. This... |
tokio | rust | async_runtime | inject.rs | use crate::runtime::scheduler::Inject;
#[test]
fn push_and_pop() {
const N: usize = 2;
let inject = Inject::new();
for i in 0..N {
assert_eq!(inject.len(), i);
let (task, _) = super::unowned(async {});
inject.push(task);
}
for i in 0..N {
assert_eq!(inject.len(), ... |
tokio | rust | async_runtime | shutdown.rs | use crate::runtime::{Builder, Handle};
#[test]
fn join_handle_cancel_on_shutdown() {
let mut builder = loom::model::Builder::new();
builder.preemption_bound = Some(2);
builder.check(|| {
use futures::future::FutureExt;
let rt = Builder::new_multi_thread()
.worker_threads(2)
... |
tokio | rust | async_runtime | yield_now.rs | use crate::runtime::park;
use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::{self, Runtime};
#[test]
fn yield_calls_park_before_scheduling_again() {
// Don't need to check all permutations
let mut loom = loom::model::Builder::default();
loom.max_permutations = Some(1);
loom.check(... |
tokio | rust | async_runtime | queue.rs | use crate::runtime::scheduler::multi_thread::{queue, Stats};
use crate::runtime::tests::{unowned, NoopSchedule};
use loom::thread;
use std::cell::RefCell;
fn new_stats() -> Stats {
Stats::new(&crate::runtime::WorkerMetrics::new())
}
#[test]
fn basic() {
loom::model(|| {
let (steal, mut local) = queue... |
tokio | rust | async_runtime | yield_now.rs | use crate::runtime::park;
use crate::runtime::{self, Runtime};
#[test]
fn yield_calls_park_before_scheduling_again() {
// Don't need to check all permutations
let mut loom = loom::model::Builder::default();
loom.max_permutations = Some(1);
loom.check(|| {
let rt = mk_runtime();
let jh ... |
tokio | rust | async_runtime | mod.rs | cfg_rt! {
pub(crate) mod current_thread;
pub(crate) use current_thread::CurrentThread;
mod defer;
use defer::Defer;
pub(crate) mod inject;
pub(crate) use inject::Inject;
use crate::runtime::TaskHooks;
use crate::runtime::WorkerMetrics;
}
cfg_rt_multi_thread! {
mod block_in_place... |
tokio | rust | async_runtime | defer.rs | use std::cell::RefCell;
use std::task::Waker;
pub(crate) struct Defer {
deferred: RefCell<Vec<Waker>>,
}
impl Defer {
pub(crate) fn new() -> Defer {
Defer {
deferred: RefCell::default(),
}
}
pub(crate) fn defer(&self, waker: &Waker) {
let mut deferred = self.deferr... |
tokio | rust | async_runtime | inject.rs | use crate::loom::sync::Mutex;
use crate::runtime::task;
mod pop;
pub(crate) use pop::Pop;
mod shared;
pub(crate) use shared::Shared;
mod synced;
pub(crate) use synced::Synced;
cfg_rt_multi_thread! {
mod rt_multi_thread;
pub(crate) use rt_multi_thread::InjectQueue;
}
mod metrics;
/// Growable, MPMC queue u... |
tokio | rust | async_runtime | time_alt.rs | use crate::runtime::scheduler::driver;
use crate::runtime::time_alt::cancellation_queue::{Receiver, Sender};
use crate::runtime::time_alt::{EntryHandle, RegistrationQueue, WakeQueue, Wheel};
use std::time::Duration;
pub(crate) fn min_duration(a: Option<Duration>, b: Option<Duration>) -> Option<Duration> {
match (a... |
tokio | rust | async_runtime | synced.rs | #![cfg_attr(
any(not(all(tokio_unstable, feature = "full")), target_family = "wasm"),
allow(dead_code)
)]
use crate::runtime::task;
pub(crate) struct Synced {
/// True if the queue is closed.
pub(super) is_closed: bool,
/// Linked-list head.
pub(super) head: Option<task::RawTask>,
/// Li... |
tokio | rust | async_runtime | rt_multi_thread.rs | use super::{Inject, Pop};
use crate::runtime::task;
use std::sync::atomic::Ordering::Release;
/// The multi-thread scheduler's inject queue. Each variant owns its queue and
/// lock topology.
pub(crate) enum InjectQueue<T: 'static> {
/// A single queue behind a single mutex.
Locked(Inject<T>),
}
impl<T: 'st... |
tokio | rust | async_runtime | pop.rs | use super::Synced;
use crate::runtime::task;
use std::marker::PhantomData;
pub(crate) struct Pop<'a, T: 'static> {
len: usize,
synced: &'a mut Synced,
_p: PhantomData<T>,
}
impl<'a, T: 'static> Pop<'a, T> {
pub(super) fn new(len: usize, synced: &'a mut Synced) -> Pop<'a, T> {
Pop {
... |
tokio | rust | async_runtime | shared.rs | use super::{Pop, Synced};
use crate::loom::sync::atomic::AtomicUsize;
use crate::runtime::task;
use std::marker::PhantomData;
use std::sync::atomic::Ordering::{Acquire, Release};
pub(crate) struct Shared<T: 'static> {
/// Number of pending tasks in the queue. This helps prevent unnecessary
/// locking in the... |
tokio | rust | async_runtime | mod.rs | use crate::loom::sync::atomic::AtomicBool;
use crate::loom::sync::Arc;
use crate::runtime::driver::{self, Driver};
use crate::runtime::scheduler::{self, Defer, Inject};
use crate::runtime::task::{
self, JoinHandle, LocalNotified, OwnedTasks, Schedule, SpawnLocation, Task,
TaskHarnessScheduleHooks,
};
use crate:... |
tokio | rust | async_runtime | overflow.rs | use crate::runtime::task;
#[cfg(test)]
use std::cell::RefCell;
pub(crate) trait Overflow<T: 'static> {
fn push(&self, task: task::Notified<T>);
fn push_batch<I>(&self, iter: I)
where
I: Iterator<Item = task::Notified<T>>;
}
#[cfg(test)]
impl<T: 'static> Overflow<T> for RefCell<Vec<task::Notified... |
tokio | rust | async_runtime | handle.rs | use crate::future::Future;
use crate::loom::sync::Arc;
use crate::runtime::scheduler::multi_thread::worker;
use crate::runtime::task::{Notified, Task, TaskHarnessScheduleHooks};
use crate::runtime::{
blocking, driver,
task::{self, JoinHandle, SpawnLocation},
TaskHooks, TaskMeta, TimerFlavor,
};
use crate::u... |
tokio | rust | async_runtime | park.rs | use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::{Arc, Condvar, Mutex};
use crate::runtime::driver::{self, Driver};
use crate::util::TryLock;
use std::sync::atomic::Ordering::SeqCst;
use std::time::{Duration, Instant};
#[cfg(loom)]
use crate::runtime::park::CURRENT_THREAD_PARK_COUNT;
pub(crate) str... |
tokio | rust | async_runtime | idle.rs | use crate::loom::sync::atomic::AtomicUsize;
use crate::runtime::scheduler::multi_thread::Shared;
use std::fmt;
use std::sync::atomic::Ordering::{self, SeqCst};
pub(super) struct Idle {
/// Tracks both the number of searching workers and the number of unparked
/// workers.
///
/// Used as a fast-path t... |
tokio | rust | async_runtime | worker.rs | use crate::loom::sync::{Arc, Mutex};
use crate::runtime;
use crate::runtime::scheduler::multi_thread::{
idle, park, queue, Counters, Handle, Idle, Overflow, Parker, Stats, TraceStatus, Unparker,
};
use crate::runtime::scheduler::{inject::InjectQueue, Defer};
use crate::runtime::task::OwnedTasks;
use crate::runtime:... |
tokio | rust | async_runtime | counters.rs | #[cfg(tokio_internal_mt_counters)]
mod imp {
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::Relaxed;
static NUM_MAINTENANCE: AtomicUsize = AtomicUsize::new(0);
static NUM_NOTIFY_LOCAL: AtomicUsize = AtomicUsize::new(0);
static NUM_UNPARKS_LOCAL: AtomicUsize = AtomicUsize::new(... |
tokio | rust | async_runtime | queue.rs | 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, Relaxed, Release};
// Use wider integers when possible to increas... |
tokio | rust | async_runtime | trace.rs | 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... |
tokio | rust | async_runtime | mod.rs | mod counters;
use counters::Counters;
mod handle;
pub(crate) use handle::Handle;
mod overflow;
pub(crate) use overflow::Overflow;
mod idle;
use self::idle::Idle;
mod stats;
pub(crate) use stats::Stats;
mod park;
pub(crate) use park::{Parker, Unparker};
pub(crate) mod queue;
mod worker;
pub(crate) use worker::{Co... |
tokio | rust | async_runtime | stats.rs | use crate::runtime::metrics::ScheduleLatencyContext;
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 u... |
tokio | rust | async_runtime | metrics.rs | use super::Handle;
use crate::runtime::WorkerMetrics;
cfg_unstable_metrics! {
use crate::runtime::SchedulerMetrics;
}
impl Handle {
pub(crate) fn num_workers(&self) -> usize {
self.shared.worker_metrics.len()
}
pub(crate) fn num_alive_tasks(&self) -> usize {
self.shared.owned.num_aliv... |
tokio | rust | async_runtime | taskdump.rs | use super::Handle;
use crate::runtime::Dump;
impl Handle {
pub(crate) async fn dump(&self) -> Dump {
let trace_status = &self.shared.trace_status;
// If a dump is in progress, block.
trace_status.start_trace_request(self).await;
let result = loop {
if let Some(result)... |
tokio | rust | async_runtime | metrics.rs | use super::Shared;
impl Shared {
pub(crate) fn injection_queue_depth(&self) -> usize {
self.inject.len()
}
}
cfg_unstable_metrics! {
impl Shared {
pub(crate) fn worker_local_queue_depth(&self, worker: usize) -> usize {
self.remotes[worker].steal.len()
}
}
} |
tokio | rust | async_runtime | taskdump.rs | use super::{Core, Handle, Shared};
use crate::loom::sync::Arc;
use crate::runtime::scheduler::multi_thread::Stats;
use crate::runtime::task::trace::trace_multi_thread;
use crate::runtime::{dump, WorkerMetrics};
use std::time::Duration;
impl Handle {
pub(super) fn trace_core(&self, mut core: Box<Core>) -> Box<Cor... |
tokio | rust | async_runtime | handle.rs | use crate::runtime::time::TimeSource;
use std::fmt;
/// Handle to time driver instance.
pub(crate) struct Handle {
pub(super) time_source: TimeSource,
pub(super) inner: super::Inner,
}
impl Handle {
/// Returns the time source associated with this handle.
pub(crate) fn time_source(&self) -> &TimeSourc... |
tokio | rust | async_runtime | source.rs | use super::MAX_SAFE_MILLIS_DURATION;
use crate::time::{Clock, Duration, Instant};
/// A structure which handles conversion from Instants to `u64` timestamps.
#[derive(Debug)]
pub(crate) struct TimeSource {
start_time: Instant,
}
impl TimeSource {
pub(crate) fn new(clock: &Clock) -> Self {
Self {
... |
tokio | rust | async_runtime | mod.rs | // Currently, rust warns when an unsafe fn contains an unsafe {} block. However,
// in the future, this will change to the reverse. For now, suppress this
// warning and generally stick with being explicit about unsafety.
#![allow(unused_unsafe)]
#![cfg_attr(not(feature = "rt"), allow(dead_code))]
mod entry;
pub(crat... |
tokio | rust | async_runtime | entry.rs | use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::AtomicU64;
use crate::loom::sync::atomic::Ordering;
use crate::runtime::scheduler;
use crate::sync::AtomicWaker;
use crate::util::linked_list;
use pin_project_lite::pin_project;
use std::task::{Context, Poll, Waker};
use std::{marker::PhantomPinned, pi... |
tokio | rust | async_runtime | mod.rs | #![cfg(all(not(target_os = "wasi"), not(target_os = "emscripten")))]
use std::task::Context;
#[cfg(not(loom))]
use futures::task::noop_waker_ref;
use crate::loom::sync::atomic::{AtomicBool, Ordering};
use crate::loom::sync::Arc;
use crate::loom::thread;
use super::TimerEntry;
fn block_on<T>(f: impl std::future::Fu... |
tokio | rust | async_runtime | mod.rs | use crate::runtime::time::{TimerHandle, TimerShared};
use crate::time::error::InsertError;
use crate::util::linked_list::LinkedList;
mod level;
pub(crate) use self::level::Expiration;
use self::level::Level;
use std::ptr::NonNull;
use super::entry::STATE_DEREGISTERED;
/// Timing wheel implementation.
///
/// This t... |
tokio | rust | async_runtime | level.rs | use crate::runtime::time::{TimerHandle, TimerShared};
use crate::util::linked_list::LinkedList;
use std::{array, fmt, ptr::NonNull};
/// Wheel for a single level in the timer. This wheel contains 64 slots.
pub(crate) struct Level {
level: usize,
/// Bit field tracking which slots currently contain entries.
... |
tokio | rust | async_runtime | core.rs | // It doesn't make sense to enforce `unsafe_op_in_unsafe_fn` for this module because
//
// * This module is doing the low-level task management that requires tons of unsafe
// operations.
// * Excessive `unsafe {}` blocks hurt readability significantly.
#![expect(unsafe_op_in_unsafe_fn)]
use crate::future::Future;
u... |
tokio | rust | async_runtime | join.rs | use crate::runtime::task::{AbortHandle, Header, RawTask};
use std::fmt;
use std::future::Future;
use std::marker::PhantomData;
use std::panic::{RefUnwindSafe, UnwindSafe};
use std::pin::Pin;
use std::task::{ready, Context, Poll, Waker};
cfg_rt! {
/// An owned permission to join on a task (await its termination).
... |
tokio | rust | async_runtime | waker.rs | use crate::runtime::task::{Header, RawTask, Schedule};
use std::marker::PhantomData;
use std::mem::ManuallyDrop;
use std::ops;
use std::ptr::NonNull;
use std::task::{RawWaker, RawWakerVTable, Waker};
pub(super) struct WakerRef<'a, S: 'static> {
waker: ManuallyDrop<Waker>,
_p: PhantomData<(&'a Header, S)>,
}
... |
tokio | rust | async_runtime | abort.rs | use crate::runtime::task::{Header, RawTask};
use std::fmt;
use std::panic::{RefUnwindSafe, UnwindSafe};
/// An owned permission to abort a spawned task, without awaiting its completion.
///
/// Unlike a [`JoinHandle`], an `AbortHandle` does *not* represent the
/// permission to await the task's completion, only to ter... |
tokio | rust | async_runtime | id.rs | use crate::runtime::context;
use std::{fmt, num::NonZeroU64};
/// An opaque ID that uniquely identifies a task relative to all other currently
/// running tasks.
///
/// A task's ID may be re-used for another task only once *both* of the
/// following happen:
/// 1. The task itself exits.
/// 2. There is no active [`... |
tokio | rust | async_runtime | error.rs | use std::any::Any;
use std::fmt;
use std::io;
use super::Id;
use crate::util::SyncWrapper;
cfg_rt! {
/// Task failed to execute to completion.
pub struct JoinError {
repr: Repr,
id: Id,
}
}
enum Repr {
Cancelled,
Panic(SyncWrapper<Box<dyn Any + Send + 'static>>),
}
impl JoinError ... |
tokio | rust | async_runtime | list.rs | use crate::future::Future;
use crate::loom::cell::UnsafeCell;
use crate::runtime::task::{JoinHandle, LocalNotified, Notified, Schedule, SpawnLocation, Task};
use crate::util::linked_list::LinkedList;
use crate::util::sharded_list::ShardedList;
use crate::loom::sync::atomic::{AtomicBool, Ordering};
use std::marker::Pha... |
tokio | rust | async_runtime | raw.rs | // It doesn't make sense to enforce `unsafe_op_in_unsafe_fn` for this module because
//
// * This module is doing the low-level task management that requires tons of unsafe
// operations.
// * Excessive `unsafe {}` blocks hurt readability significantly.
#![expect(unsafe_op_in_unsafe_fn)]
use crate::future::Future;
u... |
tokio | rust | async_runtime | harness.rs | use crate::future::Future;
use crate::runtime::task::core::{Cell, Core, Header, Trailer};
use crate::runtime::task::state::{Snapshot, State};
use crate::runtime::task::waker::waker_ref;
use crate::runtime::task::{Id, JoinError, Notified, RawTask, Schedule, Task};
#[cfg(tokio_unstable)]
use crate::runtime::TaskMeta;
us... |
tokio | rust | async_runtime | mod.rs | mod core;
use self::core::Cell;
use self::core::Header;
mod error;
pub use self::error::JoinError;
mod harness;
use self::harness::Harness;
mod id;
pub use id::{id, try_id, Id};
#[cfg(feature = "rt")]
mod abort;
mod join;
#[cfg(feature = "rt")]
pub use self::abort::AbortHandle;
pub use self::join::JoinHandle;
mo... |
tokio | rust | async_runtime | state.rs | use crate::loom::sync::atomic::AtomicUsize;
use std::fmt;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release};
pub(super) struct State {
val: AtomicUsize,
}
/// Current state value.
#[derive(Copy, Clone)]
pub(super) struct Snapshot(usize);
type UpdateResult = Result<Snapshot, Snapshot>;
/// The task is... |
tokio | rust | async_runtime | symbol.rs | use backtrace::BacktraceSymbol;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::ptr;
/// A symbol in a backtrace.
///
/// This wrapper type serves two purposes. The first is that it provides a
/// representation of a symbol that can be inserted into hashmaps and hashsets;
/// the [`backtrace`] crate does not def... |
tokio | rust | async_runtime | tree.rs | use std::collections::{hash_map::DefaultHasher, HashMap, HashSet};
use std::fmt;
use std::hash::{Hash, Hasher};
use super::{Backtrace, Symbol, SymbolTrace, Trace};
/// An adjacency list representation of an execution tree.
///
/// This tree provides a convenient intermediate representation for formatting
/// [`Trace`... |
tokio | rust | async_runtime | mod.rs | 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::... |
tokio | rust | async_runtime | trace_impl.rs | use std::ptr;
use crate::runtime::task::trace::{Trace, TraceMeta};
/// Capture a backtrace via `backtrace::trace` and collect it into `trace`.
pub(crate) fn trace_leaf(meta: &TraceMeta, trace: &mut Trace) {
let mut frames: Vec<backtrace::BacktraceFrame> = vec![];
let mut above_leaf = false;
if let Some(r... |
tokio | rust | async_runtime | mod.rs | #![cfg_attr(not(feature = "rt"), allow(dead_code))]
use crate::runtime::{driver, io};
use crate::signal::registry::globals;
use mio::net::UnixStream;
use std::io::{self as std_io, Read};
use std::sync::{Arc, Weak};
use std::time::Duration;
/// Responsible for registering wakeups when an OS signal is received, and
/... |
tokio | rust | async_runtime | timeout.rs | use crate::{
task::coop,
time::{error::Elapsed, Duration, Instant, Sleep},
util::trace,
};
use pin_project_lite::pin_project;
use std::future::{Future, IntoFuture};
use std::pin::Pin;
use std::task::{self, Poll};
/// Requires a `Future` to complete before the specified duration has elapsed.
///
/// If the... |
tokio | rust | async_runtime | clock.rs | #![cfg_attr(not(feature = "rt"), allow(dead_code))]
cfg_not_test_util! {
use crate::time::{Instant};
#[derive(Debug, Clone)]
pub(crate) struct Clock {}
pub(crate) fn now() -> Instant {
Instant::from_std(std::time::Instant::now())
}
impl Clock {
pub(crate) fn new(_enable_paus... |
tokio | rust | async_runtime | error.rs | use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the operation will never be able
/// to com... |
tokio | rust | async_runtime | interval.rs | use crate::time::{safe_delay, sleep_until, Duration, Instant, Sleep};
use crate::util::trace;
use std::future::{poll_fn, Future};
use std::panic::Location;
use std::pin::Pin;
use std::task::{ready, Context, Poll};
/// Creates new [`Interval`] that yields with interval of `period`. The first
/// tick completes immedia... |
tokio | rust | async_runtime | mod.rs | fn safe_delay(duration: Duration) -> Duration {
// Roughly 30 years from now.
// 1000 years overflows on macOS, 100 years overflows on FreeBSD.
duration.min(Duration::from_secs(86400 * 365 * 30))
}
mod clock;
pub(crate) use self::clock::Clock;
cfg_test_util! {
pub use clock::{advance, pause, resume};
}... |
tokio | rust | async_runtime | instant.rs | #![allow(clippy::trivially_copy_pass_by_ref)]
use std::fmt;
use std::ops;
use std::time::Duration;
/// A measurement of a monotonically nondecreasing clock.
/// Opaque and useful only with `Duration`.
///
/// Instants are always guaranteed to be no less than any previously measured
/// instant when created, and are o... |
tokio | rust | async_runtime | sleep.rs | use crate::runtime::{scheduler, Timer};
use crate::time::{error::Error, safe_delay, Duration, Instant};
use crate::util::trace;
use pin_project_lite::pin_project;
use std::future::Future;
use std::panic::Location;
use std::pin::Pin;
use std::task::{self, ready, Poll};
/// Waits until `deadline` is reached.
///
/// No... |
tokio | rust | async_runtime | addr_of.rs | macro_rules! generate_addr_of_methods {
(
impl<$($gen:ident)*> $struct_name:ty {$(
$(#[$attrs:meta])*
$vis:vis unsafe fn $fn_name:ident(self: NonNull<Self>) -> NonNull<$field_type:ty> {
&self$(.$field_name:tt)+
}
)*}
) => {
impl<$($gen)*> $struct_name {$(
... |
tokio | rust | async_runtime | join.rs | macro_rules! doc {
($join:item) => {
/// Waits on multiple concurrent branches, returning when **all** branches
/// complete.
///
/// The `join!` macro must be used inside of async functions, closures, and
/// blocks.
///
/// The `join!` macro takes a list of ... |
tokio | rust | async_runtime | support.rs | cfg_macros! {
pub use crate::future::maybe_done::maybe_done;
pub use std::future::poll_fn;
pub use crate::macros::join::{BiasedRotator, Rotator, RotatorSelect, SelectNormal, SelectBiased};
#[doc(hidden)]
pub fn thread_rng_n(n: u32) -> u32 {
crate::runtime::context::thread_rng_n(n)
}
... |
tokio | rust | async_runtime | thread_local.rs | #[cfg(all(loom, test))]
macro_rules! tokio_thread_local {
($(#[$attrs:meta])* $vis:vis static $name:ident: $ty:ty = const { $expr:expr } $(;)?) => {
loom::thread_local! {
$(#[$attrs])*
$vis static $name: $ty = $expr;
}
};
($($tts:tt)+) => { loom::thread_local!{ $($tt... |
tokio | rust | async_runtime | pin.rs | /// Pins a value on the stack.
///
/// Calls to `async fn` return anonymous [`Future`] values that are `!Unpin`.
/// These values must be pinned before they can be polled. Calling `.await` will
/// handle this, but consumes the future. If it is required to call `.await` on
/// a `&mut _` reference, the caller is respon... |
tokio | rust | async_runtime | cfg.rs | #![allow(unused_macros)]
/// Allows specifying arbitrary combinations of features and config flags,
/// which are also propagated to `docsrs` config.
///
/// Each contained item will have the annotations applied
///
/// ## Example usage:
/// ```no-compile
/// feature! {
/// #![any(
/// feature = "process",
/// ... |
tokio | rust | async_runtime | trace.rs | cfg_trace! {
macro_rules! trace_op {
($name:expr, $readiness:literal) => {
tracing::trace!(
target: "runtime::resource::poll_op",
op_name = $name,
is_ready = $readiness
);
}
}
macro_rules! trace_poll_op {
($name... |
tokio | rust | async_runtime | mod.rs | #![cfg_attr(not(feature = "full"), allow(unused_macros))]
#[macro_use]
mod cfg;
#[macro_use]
mod loom;
#[macro_use]
mod pin;
#[macro_use]
mod thread_local;
#[macro_use]
mod addr_of;
cfg_trace! {
#[macro_use]
mod trace;
}
cfg_macros! {
#[macro_use]
mod select;
#[macro_use]
mod join;
... |
tokio | rust | async_runtime | select.rs | macro_rules! doc {
($select:item) => {
/// Waits on multiple concurrent branches, returning when the **first** branch
/// completes, cancelling the remaining branches.
///
/// The `select!` macro must be used inside of async functions, closures, and
/// blocks.
///
... |
tokio | rust | async_runtime | try_join.rs | macro_rules! doc {
($try_join:item) => {
/// Waits on multiple concurrent branches, returning when **all** branches
/// complete with `Ok(_)` or on the first `Err(_)`.
///
/// The `try_join!` macro must be used inside of async functions, closures, and
/// blocks.
///
... |
tokio | rust | async_runtime | task_local.rs | use pin_project_lite::pin_project;
use std::cell::RefCell;
use std::error::Error;
use std::future::Future;
use std::marker::PhantomPinned;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{fmt, mem, thread};
/// Declares a new task-local key of type [`tokio::task::LocalKey`].
///
/// # Syntax
///
/// The ma... |
tokio | rust | async_runtime | yield_now.rs | use crate::runtime::context;
use std::future::poll_fn;
use std::task::{ready, Poll};
/// Yields execution back to the Tokio runtime.
///
/// A task yields by awaiting on `yield_now()`, and may resume when that future
/// completes (with no output.) The current task will be re-added as a pending
/// task at the _back_... |
tokio | rust | async_runtime | local.rs | use crate::loom::cell::UnsafeCell;
use crate::loom::sync::{Arc, Mutex};
use crate::runtime;
use crate::runtime::task::{
self, JoinHandle, LocalOwnedTasks, SpawnLocation, Task, TaskHarnessScheduleHooks,
};
use crate::runtime::{context, AutoBox, ThreadId};
use crate::sync::AtomicWaker;
use crate::util::trace::SpawnMe... |
tokio | rust | async_runtime | join_set.rs | use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{fmt, panic};
use crate::runtime::Handle;
use crate::task::Id;
use crate::task::{unconstrained, AbortHandle, JoinError, JoinHandle, LocalSet};
use crate::util::IdleNotifiedSet;
/// A collection of tasks spawned on a Tokio runtime.
//... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.