repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/typeid.rs
tokio/src/util/typeid.rs
use std::{ any::TypeId, marker::PhantomData, mem::{self, ManuallyDrop}, }; // SAFETY: this function does not compare lifetimes. Values returned as `Ok` // may have their lifetimes extended. pub(super) unsafe fn try_transmute<Src, Target: 'static>(x: Src) -> Result<Target, Src> { if nonstatic_typeid::<S...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/ptr_expose.rs
tokio/src/util/ptr_expose.rs
//! Utility for helping miri understand our exposed pointers. //! //! During normal execution, this module is equivalent to pointer casts. However, when running //! under miri, pointer casts are replaced with lookups in a hash map. This makes Tokio compatible //! with strict provenance when running under miri (which co...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/trace.rs
tokio/src/util/trace.rs
cfg_rt! { use std::marker::PhantomData; #[derive(Copy, Clone)] pub(crate) struct SpawnMeta<'a> { /// The name of the task #[cfg(all(tokio_unstable, feature = "tracing"))] pub(crate) name: Option<&'a str>, /// The original size of the future or function being spawned ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/as_ref.rs
tokio/src/util/as_ref.rs
use super::typeid; #[derive(Debug)] pub(crate) enum OwnedBuf { Vec(Vec<u8>), #[cfg(feature = "io-util")] Bytes(bytes::Bytes), } impl AsRef<[u8]> for OwnedBuf { fn as_ref(&self) -> &[u8] { match self { Self::Vec(vec) => vec, #[cfg(feature = "io-util")] Self::...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/markers.rs
tokio/src/util/markers.rs
/// Marker for types that are `Sync` but not `Send` #[allow(dead_code)] pub(crate) struct SyncNotSend(#[allow(dead_code)] *mut ()); unsafe impl Sync for SyncNotSend {} cfg_rt! { pub(crate) struct NotSendOrSync(#[allow(dead_code)] *mut ()); }
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/error.rs
tokio/src/util/error.rs
// Some combinations of features may not use these constants. #![cfg_attr(not(feature = "full"), allow(dead_code))] /// Error string explaining that the Tokio context hasn't been instantiated. pub(crate) const CONTEXT_MISSING_ERROR: &str = "there is no reactor running, must be called from the context of a Tokio 1....
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/rand.rs
tokio/src/util/rand.rs
cfg_rt! { mod rt; pub(crate) use rt::RngSeedGenerator; cfg_unstable! { mod rt_unstable; } } /// A seed for random number generation. /// /// In order to make certain functions within a runtime deterministic, a seed /// can be specified at the time of creation. #[allow(unreachable_pub)] #[deriv...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/mod.rs
tokio/src/util/mod.rs
cfg_io_driver! { pub(crate) mod bit; } #[cfg(feature = "fs")] pub(crate) mod as_ref; #[cfg(feature = "rt")] pub(crate) mod atomic_cell; #[cfg(feature = "net")] mod blocking_check; #[cfg(feature = "net")] #[allow(unused_imports)] pub(crate) use blocking_check::check_socket_for_blocking; pub(crate) mod metric_ato...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/memchr.rs
tokio/src/util/memchr.rs
//! Search for a byte in a byte array using libc. //! //! When nothing pulls in libc, then just use a trivial implementation. Note //! that we only depend on libc on unix. #[cfg(not(all(unix, feature = "libc")))] pub(crate) fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.iter().position(|val| ne...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/cacheline.rs
tokio/src/util/cacheline.rs
#![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))] use std::ops::{Deref, DerefMut}; /// Pads and aligns a value to the length of a cache line. #[derive(Clone, Copy, Default, Hash, PartialEq, Eq)] // Starting from Intel's Sandy Bridge, spatial prefetcher is now pulling pairs of 64-byte cache // line...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/linked_list.rs
tokio/src/util/linked_list.rs
#![cfg_attr(not(feature = "full"), allow(dead_code))] // It doesn't make sense to enforce `unsafe_op_in_unsafe_fn` for this module because // // * The intrusive linked list naturally relies on unsafe operations. // * Excessive `unsafe {}` blocks hurt readability significantly. // TODO: replace with `#[expect(unsafe_op_...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/sync_wrapper.rs
tokio/src/util/sync_wrapper.rs
//! This module contains a type that can make `Send + !Sync` types `Sync` by //! disallowing all immutable access to the value. //! //! A similar primitive is provided in the `sync_wrapper` crate. use std::any::Any; pub(crate) struct SyncWrapper<T> { value: T, } // safety: The SyncWrapper being send allows you t...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/rc_cell.rs
tokio/src/util/rc_cell.rs
use crate::loom::cell::UnsafeCell; use std::rc::Rc; /// This is exactly like `Cell<Option<Rc<T>>>`, except that it provides a `get` /// method even though `Rc` is not `Copy`. pub(crate) struct RcCell<T> { inner: UnsafeCell<Option<Rc<T>>>, } impl<T> RcCell<T> { #[cfg(not(all(loom, test)))] pub(crate) cons...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/metric_atomics.rs
tokio/src/util/metric_atomics.rs
use std::sync::atomic::{AtomicUsize, Ordering}; cfg_64bit_metrics! { use std::sync::atomic::AtomicU64; } /// `AtomicU64` that is a no-op on platforms without 64-bit atomics /// /// When used on platforms without 64-bit atomics, writes to this are no-ops. /// The `load` method is only defined when 64-bit atomics a...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/atomic_cell.rs
tokio/src/util/atomic_cell.rs
use crate::loom::sync::atomic::AtomicPtr; use std::ptr; use std::sync::atomic::Ordering::AcqRel; pub(crate) struct AtomicCell<T> { data: AtomicPtr<T>, } unsafe impl<T: Send> Send for AtomicCell<T> {} unsafe impl<T: Send> Sync for AtomicCell<T> {} impl<T> AtomicCell<T> { pub(crate) fn new(data: Option<Box<T>...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/idle_notified_set.rs
tokio/src/util/idle_notified_set.rs
//! This module defines an `IdleNotifiedSet`, which is a collection of elements. //! Each element is intended to correspond to a task, and the collection will //! keep track of which tasks have had their waker notified, and which have not. //! //! Each entry in the set holds some user-specified value. The value's type ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/try_lock.rs
tokio/src/util/try_lock.rs
use crate::loom::sync::atomic::AtomicBool; use std::cell::UnsafeCell; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::sync::atomic::Ordering::SeqCst; pub(crate) struct TryLock<T> { locked: AtomicBool, data: UnsafeCell<T>, } pub(crate) struct LockGuard<'a, T> { lock: &'a TryLock<T>...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/rand/rt_unstable.rs
tokio/src/util/rand/rt_unstable.rs
use super::RngSeed; use std::collections::hash_map::DefaultHasher; use std::hash::Hasher; impl RngSeed { /// Generates a seed from the provided byte slice. /// /// # Example /// /// ``` /// # use tokio::runtime::RngSeed; /// let seed = RngSeed::from_bytes(b"make me a seed"); /// ``` ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/util/rand/rt.rs
tokio/src/util/rand/rt.rs
use super::{FastRand, RngSeed}; use std::sync::Mutex; /// A deterministic generator for seeds (and other generators). /// /// Given the same initial seed, the generator will output the same sequence of seeds. /// /// Since the seed generator will be kept in a runtime handle, we need to wrap `FastRand` /// in a Mutex ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/process/kill.rs
tokio/src/process/kill.rs
use std::io; /// An interface for killing a running process. pub(crate) trait Kill { /// Forcefully kills the process. fn kill(&mut self) -> io::Result<()>; } impl<T: Kill> Kill for &mut T { fn kill(&mut self) -> io::Result<()> { (**self).kill() } }
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/process/windows.rs
tokio/src/process/windows.rs
//! Windows asynchronous process handling. //! //! Like with Unix we don't actually have a way of registering a process with an //! IOCP object. As a result we similarly need another mechanism for getting a //! signal when a process has exited. For now this is implemented with the //! `RegisterWaitForSingleObject` func...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/process/mod.rs
tokio/src/process/mod.rs
//! An implementation of asynchronous process management for Tokio. //! //! This module provides a [`Command`] struct that imitates the interface of the //! [`std::process::Command`] type in the standard library, but provides asynchronous versions of //! functions that create processes. These functions (`spawn`, `statu...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
true
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/process/unix/reap.rs
tokio/src/process/unix/reap.rs
use crate::process::imp::orphan::{OrphanQueue, Wait}; use crate::process::kill::Kill; use crate::signal::unix::InternalStream; use std::future::Future; use std::io; use std::ops::Deref; use std::pin::Pin; use std::process::ExitStatus; use std::task::Context; use std::task::Poll; /// Orchestrates between registering i...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/process/unix/orphan.rs
tokio/src/process/unix/orphan.rs
use crate::loom::sync::{Mutex, MutexGuard}; use crate::runtime::signal::Handle as SignalHandle; use crate::signal::unix::{signal_with_handle, SignalKind}; use crate::sync::watch; use std::io; use std::process::ExitStatus; /// An interface for waiting on a process to exit. pub(crate) trait Wait { /// Get the identi...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/process/unix/mod.rs
tokio/src/process/unix/mod.rs
//! Unix handling of child processes. //! //! Right now the only "fancy" thing about this is how we implement the //! `Future` implementation on `Child` to get the exit status. Unix offers //! no way to register a child with epoll, and the only real way to get a //! notification when a process exits is the SIGCHLD sign...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/process/unix/pidfd_reaper.rs
tokio/src/process/unix/pidfd_reaper.rs
use crate::{ io::{interest::Interest, PollEvented}, process::{ imp::{orphan::Wait, OrphanQueue}, kill::Kill, }, util::error::RUNTIME_SHUTTING_DOWN_ERROR, }; use libc::{syscall, SYS_pidfd_open, ENOSYS, PIDFD_NONBLOCK}; use mio::{event::Source, unix::SourceFd}; use std::{ fs::File, ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/loom.rs
tokio/src/macros/loom.rs
macro_rules! if_loom { ($($t:tt)*) => {{ #[cfg(loom)] { $($t)* } }} }
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/support.rs
tokio/src/macros/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) } ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/select.rs
tokio/src/macros/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. /// ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
true
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/try_join.rs
tokio/src/macros/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. /// ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/trace.rs
tokio/src/macros/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/addr_of.rs
tokio/src/macros/addr_of.rs
//! This module defines a macro that lets you go from a raw pointer to a struct //! to a raw pointer to a field of the struct. 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<...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/mod.rs
tokio/src/macros/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; ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/join.rs
tokio/src/macros/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 ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/pin.rs
tokio/src/macros/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/thread_local.rs
tokio/src/macros/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/macros/cfg.rs
tokio/src/macros/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", /// ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/config.rs
tokio/src/runtime/config.rs
#![cfg_attr( any(not(all(tokio_unstable, feature = "full")), target_family = "wasm"), allow(dead_code) )] use crate::runtime::{Callback, TaskCallback}; use crate::util::RngSeedGenerator; pub(crate) struct Config { /// How many ticks before pulling a task from the global/remote queue? pub(crate) global_...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/park.rs
tokio/src/runtime/park.rs
#![cfg_attr(not(feature = "full"), allow(dead_code))] use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::{Arc, Condvar, Mutex}; use std::sync::atomic::Ordering::SeqCst; use std::time::Duration; #[derive(Debug)] pub(crate) struct ParkThread { inner: Arc<Inner>, } /// Unblocks a thread that was bl...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/builder.rs
tokio/src/runtime/builder.rs
#![cfg_attr(loom, allow(unused_imports))] use crate::runtime::handle::Handle; use crate::runtime::{ blocking, driver, Callback, HistogramBuilder, Runtime, TaskCallback, TimerFlavor, }; #[cfg(tokio_unstable)] use crate::runtime::{metrics::HistogramConfiguration, LocalOptions, LocalRuntime, TaskMeta}; use crate::uti...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
true
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/process.rs
tokio/src/runtime/process.rs
#![cfg_attr(not(feature = "rt"), allow(dead_code))] //! Process driver. use crate::process::unix::GlobalOrphanQueue; use crate::runtime::driver; use crate::runtime::signal::{Driver as SignalDriver, Handle as SignalHandle}; use std::time::Duration; /// Responsible for cleaning up orphaned child processes on Unix pla...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/id.rs
tokio/src/runtime/id.rs
use std::fmt; use std::num::NonZeroU64; /// An opaque ID that uniquely identifies a runtime relative to all other currently /// running runtimes. /// /// # Notes /// /// - Runtime IDs are unique relative to other *currently running* runtimes. /// When a runtime completes, the same ID may be used for another runtime....
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/thread_id.rs
tokio/src/runtime/thread_id.rs
use std::num::NonZeroU64; #[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)] pub(crate) struct ThreadId(NonZeroU64); impl ThreadId { pub(crate) fn next() -> Self { use crate::loom::sync::atomic::{Ordering::Relaxed, StaticAtomicU64}; static NEXT_ID: StaticAtomicU64 = StaticAtomicU64::new(0); ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/dump.rs
tokio/src/runtime/dump.rs
//! Snapshots of runtime state. //! //! See [`Handle::dump`][crate::runtime::Handle::dump]. use crate::task::Id; use std::{fmt, future::Future, path::Path}; pub use crate::runtime::task::trace::Root; /// A snapshot of a runtime's state. /// /// See [`Handle::dump`][crate::runtime::Handle::dump]. #[derive(Debug)] pub...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/runtime.rs
tokio/src/runtime/runtime.rs
use super::BOX_FUTURE_THRESHOLD; use crate::runtime::blocking::BlockingPool; use crate::runtime::scheduler::CurrentThread; use crate::runtime::{context, EnterGuard, Handle}; use crate::task::JoinHandle; use crate::util::trace::SpawnMeta; use std::future::Future; use std::mem; use std::time::Duration; cfg_rt_multi_thr...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/mod.rs
tokio/src/runtime/mod.rs
//! The Tokio runtime. //! //! Unlike other Rust programs, asynchronous applications require runtime //! support. In particular, the following runtime services are necessary: //! //! * An **I/O event loop**, called the driver, which drives I/O resources and //! dispatches I/O events to tasks that depend on them. //! ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/context.rs
tokio/src/runtime/context.rs
use crate::loom::thread::AccessError; use crate::task::coop; use std::cell::Cell; #[cfg(any(feature = "rt", feature = "macros"))] use crate::util::rand::FastRand; cfg_rt! { mod blocking; pub(crate) use blocking::{disallow_block_in_place, try_enter_blocking_region, BlockingRegionGuard}; mod current; ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/driver.rs
tokio/src/runtime/driver.rs
//! Abstracts out the entire chain of runtime sub-drivers into common types. // Eventually, this file will see significant refactoring / cleanup. For now, we // don't need to worry much about dead code with certain feature permutations. #![cfg_attr( any(not(all(tokio_unstable, feature = "full")), target_family = "...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/handle.rs
tokio/src/runtime/handle.rs
use crate::runtime; use crate::runtime::{context, scheduler, RuntimeFlavor, RuntimeMetrics}; /// Handle to the runtime. /// /// The handle is internally reference-counted and can be freely cloned. A handle can be /// obtained using the [`Runtime::handle`] method. /// /// [`Runtime::handle`]: crate::runtime::Runtime::h...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/task_hooks.rs
tokio/src/runtime/task_hooks.rs
use super::Config; use std::marker::PhantomData; impl TaskHooks { pub(crate) fn spawn(&self, meta: &TaskMeta<'_>) { if let Some(f) = self.task_spawn_callback.as_ref() { f(meta) } } #[allow(dead_code)] pub(crate) fn from_config(config: &Config) -> Self { Self { ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/inject.rs
tokio/src/runtime/tests/inject.rs
use crate::runtime::scheduler::inject; #[test] fn push_and_pop() { const N: usize = 2; let (inject, mut synced) = inject::Shared::new(); for i in 0..N { assert_eq!(inject.len(), i); let (task, _) = super::unowned(async {}); unsafe { inject.push(&mut synced, task) }; } for...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_current_thread.rs
tokio/src/runtime/tests/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_oneshot.rs
tokio/src/runtime/tests/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 }; ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_multi_thread.rs
tokio/src/runtime/tests/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/mod.rs
tokio/src/runtime/tests/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_join_set.rs
tokio/src/runtime/tests/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....
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/task.rs
tokio/src/runtime/tests/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_blocking.rs
tokio/src/runtime/tests/loom_blocking.rs
use crate::runtime::{self, Runtime}; use std::sync::Arc; #[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(); crate::task::spawn...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/task_combinations.rs
tokio/src/runtime/tests/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/queue.rs
tokio/src/runtime/tests/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_local.rs
tokio/src/runtime/tests/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_current_thread/yield_now.rs
tokio/src/runtime/tests/loom_current_thread/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 ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_multi_thread/shutdown.rs
tokio/src/runtime/tests/loom_multi_thread/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) ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_multi_thread/yield_now.rs
tokio/src/runtime/tests/loom_multi_thread/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(...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/tests/loom_multi_thread/queue.rs
tokio/src/runtime/tests/loom_multi_thread/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/io.rs
tokio/src/runtime/metrics/io.rs
#![cfg_attr(not(feature = "net"), allow(dead_code))] use crate::util::metric_atomics::MetricAtomicU64; use std::sync::atomic::Ordering::Relaxed; #[derive(Default)] pub(crate) struct IoDriverMetrics { pub(super) fd_registered_count: MetricAtomicU64, pub(super) fd_deregistered_count: MetricAtomicU64, pub(su...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/batch.rs
tokio/src/runtime/metrics/batch.rs
use crate::runtime::metrics::WorkerMetrics; cfg_unstable_metrics! { use crate::runtime::metrics::HistogramBatch; } use std::sync::atomic::Ordering::Relaxed; use std::time::{Duration, Instant}; pub(crate) struct MetricsBatch { /// The total busy duration in nanoseconds. busy_duration_total: u64, /// ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/worker.rs
tokio/src/runtime/metrics/worker.rs
use crate::runtime::Config; use crate::util::metric_atomics::{MetricAtomicU64, MetricAtomicUsize}; use std::sync::atomic::Ordering::Relaxed; use std::sync::Mutex; use std::thread::ThreadId; cfg_unstable_metrics! { use crate::runtime::metrics::Histogram; } /// Retrieve runtime worker metrics. /// /// **Note**: Thi...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/runtime.rs
tokio/src/runtime/metrics/runtime.rs
use crate::runtime::Handle; use std::time::Duration; cfg_64bit_metrics! { use std::sync::atomic::Ordering::Relaxed; } cfg_unstable_metrics! { use std::ops::Range; use std::thread::ThreadId; } /// Handle to the runtime's metrics. /// /// This handle is internally reference-counted and can be freely cloned...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
true
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/mod.rs
tokio/src/runtime/metrics/mod.rs
//! This module contains information need to view information about how the //! runtime is performing. //! //! **Note**: This is an [unstable API][unstable]. The public API of types in //! this module may break in 1.x releases. See [the documentation on unstable //! features][unstable] for details. //! //! [unstable]: ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/mock.rs
tokio/src/runtime/metrics/mock.rs
//! This file contains mocks of the types in src/runtime/metrics pub(crate) struct SchedulerMetrics {} #[derive(Clone, Default)] pub(crate) struct HistogramBuilder {} impl SchedulerMetrics { pub(crate) fn new() -> Self { Self {} } /// Increment the number of tasks scheduled externally pub(cr...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/histogram.rs
tokio/src/runtime/metrics/histogram.rs
mod h2_histogram; pub use h2_histogram::{InvalidHistogramConfiguration, LogHistogram, LogHistogramBuilder}; use crate::util::metric_atomics::MetricAtomicU64; use std::sync::atomic::Ordering::Relaxed; use crate::runtime::metrics::batch::duration_as_u64; use std::cmp; use std::ops::Range; use std::time::Duration; #[d...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/scheduler.rs
tokio/src/runtime/metrics/scheduler.rs
use crate::loom::sync::atomic::Ordering::Relaxed; use crate::util::metric_atomics::MetricAtomicU64; /// Retrieves metrics from the Tokio runtime. /// /// **Note**: This is an [unstable API][unstable]. The public API of this type /// may break in 1.x releases. See [the documentation on unstable /// features][unstable] ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/metrics/histogram/h2_histogram.rs
tokio/src/runtime/metrics/histogram/h2_histogram.rs
use crate::runtime::metrics::batch::duration_as_u64; use std::cmp; use std::error::Error; use std::fmt::{Display, Formatter}; use std::time::Duration; const DEFAULT_MIN_VALUE: Duration = Duration::from_nanos(100); const DEFAULT_MAX_VALUE: Duration = Duration::from_secs(60); /// Default precision is 2^-2 = 25% max err...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/time/source.rs
tokio/src/runtime/time/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 { ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/time/mod.rs
tokio/src/runtime/time/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))] //! Time driver. mo...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/time/handle.rs
tokio/src/runtime/time/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/time/entry.rs
tokio/src/runtime/time/entry.rs
//! Timer state structures. //! //! This module contains the heart of the intrusive timer implementation, and as //! such the structures inside are full of tricky concurrency and unsafe code. //! //! # Ground rules //! //! The heart of the timer implementation here is the [`TimerShared`] structure, //! shared between t...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/time/tests/mod.rs
tokio/src/runtime/time/tests/mod.rs
#![cfg(not(target_os = "wasi"))] use std::{task::Context, time::Duration}; #[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::Future<Output = T>) ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/time/wheel/level.rs
tokio/src/runtime/time/wheel/level.rs
use crate::runtime::time::{EntryList, TimerHandle, TimerShared}; 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. /// /// Using a bit fiel...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/time/wheel/mod.rs
tokio/src/runtime/time/wheel/mod.rs
use crate::runtime::time::{TimerHandle, TimerShared}; use crate::time::error::InsertError; mod level; pub(crate) use self::level::Expiration; use self::level::Level; use std::{array, ptr::NonNull}; use super::entry::STATE_DEREGISTERED; use super::EntryList; /// Timing wheel implementation. /// /// This type provide...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/inject.rs
tokio/src/runtime/scheduler/inject.rs
//! Inject queue used to send wakeups to a work-stealing scheduler 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; } mod metrics; /// Gro...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/lock.rs
tokio/src/runtime/scheduler/lock.rs
/// A lock (mutex) yielding generic data. pub(crate) trait Lock<T> { type Handle: AsMut<T>; fn lock(self) -> Self::Handle; }
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/block_in_place.rs
tokio/src/runtime/scheduler/block_in_place.rs
use crate::runtime::scheduler; #[track_caller] pub(crate) fn block_in_place<F, R>(f: F) -> R where F: FnOnce() -> R, { scheduler::multi_thread::block_in_place(f) }
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/defer.rs
tokio/src/runtime/scheduler/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/mod.rs
tokio/src/runtime/scheduler/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/inject/rt_multi_thread.rs
tokio/src/runtime/scheduler/inject/rt_multi_thread.rs
use super::{Shared, Synced}; use crate::runtime::scheduler::Lock; use crate::runtime::task; use std::sync::atomic::Ordering::Release; impl<'a> Lock<Synced> for &'a mut Synced { type Handle = &'a mut Synced; fn lock(self) -> Self::Handle { self } } impl AsMut<Synced> for Synced { fn as_mut(&...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/inject/synced.rs
tokio/src/runtime/scheduler/inject/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/inject/pop.rs
tokio/src/runtime/scheduler/inject/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 { ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/inject/metrics.rs
tokio/src/runtime/scheduler/inject/metrics.rs
use super::Inject; impl<T: 'static> Inject<T> { pub(crate) fn len(&self) -> usize { self.shared.len() } }
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/inject/shared.rs
tokio/src/runtime/scheduler/inject/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/util/mod.rs
tokio/src/runtime/scheduler/util/mod.rs
#[cfg(all(tokio_unstable, feature = "time", feature = "rt-multi-thread"))] pub(in crate::runtime) mod time_alt;
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/util/time_alt.rs
tokio/src/runtime/scheduler/util/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/current_thread/mod.rs
tokio/src/runtime/scheduler/current_thread/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, OwnedTasks, Schedule, SpawnLocation, Task, TaskHarnessScheduleHooks, }; use crate::runtime::{ blo...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/multi_thread/idle.rs
tokio/src/runtime/scheduler/multi_thread/idle.rs
//! Coordinates idling workers 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. /...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/multi_thread/stats.rs
tokio/src/runtime/scheduler/multi_thread/stats.rs
use crate::runtime::{Config, MetricsBatch, WorkerMetrics}; use std::time::{Duration, Instant}; /// Per-worker statistics. This is used for both tuning the scheduler and /// reporting runtime-level metrics/stats. pub(crate) struct Stats { /// The metrics batch used to report runtime-level metrics/stats to the ...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/multi_thread/park.rs
tokio/src/runtime/scheduler/multi_thread/park.rs
//! Parks the runtime. //! //! A combination of the various resource driver park handles. 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, I...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/multi_thread/overflow.rs
tokio/src/runtime/scheduler/multi_thread/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/multi_thread/trace.rs
tokio/src/runtime/scheduler/multi_thread/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...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false
tokio-rs/tokio
https://github.com/tokio-rs/tokio/blob/41d1877689f8669902b003a6affce60bdfeb3025/tokio/src/runtime/scheduler/multi_thread/counters.rs
tokio/src/runtime/scheduler/multi_thread/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(...
rust
MIT
41d1877689f8669902b003a6affce60bdfeb3025
2026-01-04T15:33:40.250594Z
false