repo
stringclasses
7 values
lang
stringclasses
2 values
aspect
stringclasses
7 values
file
stringlengths
5
48
content
stringlengths
283
144k
tokio
rust
async_runtime
io_read_exact.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::io; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf}; use tokio_...
tokio
rust
async_runtime
tcp_stream.rs
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), ))] use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use ...
tokio
rust
async_runtime
sync_barrier.rs
#![allow(clippy::unnecessary_operation)] #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use tokio::sync::Barrier; use tokio_test::task::spawn; use tokio_test::{assert_pending, assert_ready}; struct IsS...
tokio
rust
async_runtime
fs_uring_file_read.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use std::future::pending; use std::io::Write; use std::path::PathBuf; use std::sync::mpsc; use std::task::Poll; use std::time::Duration; use tempfile::NamedTempFile; use tokio::fs::File; use to...
tokio
rust
async_runtime
io_read_line.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::io::ErrorKind; use std::str::Utf8Error; use tokio::io::{AsyncBufReadExt, BufReader, Error}; use tokio_test::{assert_...
tokio
rust
async_runtime
io_copy_bidirectional.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind() use std::io::ErrorKind; use std::time::Duration; use tokio::io::{ self, copy_bidirectional, copy_bidirectional_with_sizes, AsyncReadExt, AsyncWriteExt, }; use tokio::net::TcpStream; use tokio::task::J...
tokio
rust
async_runtime
macros_try_join.rs
#![cfg(feature = "macros")] #![allow(clippy::disallowed_names)] use std::{convert::Infallible, sync::Arc}; use tokio::sync::{oneshot, Semaphore}; use tokio_test::{assert_pending, assert_ready, task}; #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_te...
tokio
rust
async_runtime
sync_mutex.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_family = "wasm...
tokio
rust
async_runtime
rt_threaded.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; use tokio::runtime; use tokio::sync::oneshot; use tokio_test::{assert_err, assert_ok, assert_pending}; use std::future::{poll_fn, Future}; use std:...
tokio
rust
async_runtime
io_lines.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::io::{Error, ErrorKind}; use std::string::FromUtf8Error; use std::time::Duration; use tokio::io::{AsyncBufReadExt, B...
tokio
rust
async_runtime
io_mem_stream.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use futures::task::noop_waker_ref; use futures::FutureExt; use std::future::Future; use std::io::IoSlice; use std::pin::{pin,...
tokio
rust
async_runtime
uds_cred.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(all(unix, not(target_os = "dragonfly"), not(miri)))] // No `getsockopt` for Unix domain sockets on miri. use tokio::net::{UnixListener, UnixStream}; use futures::future::try_join; use libc::getegid; use libc::geteuid; #[tokio::test] #[cfg_attr( target_...
tokio
rust
async_runtime
fs_uring_read.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use futures::future::Future; use std::future::{pending, poll_fn}; use std::io::Write; use std::path::PathBuf; use std::sync::mpsc; use std::task::{Context, Poll, Waker}; use std::time::Duration...
tokio
rust
async_runtime
signal_drop_signal.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No `sigaction` in miri. mod support { pub mod signal; } use support::signal::send_signal; use tokio::signal::unix::{signal, SignalKind}; #[tokio::test] async fn dropping_signal_does_not_deregister_any_other_instances() { ...
tokio
rust
async_runtime
io_read_to_string.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::io; use std::str::Utf8Error; use tokio::io::AsyncReadExt; use tokio_test::assert_ok; use tokio_test::io::Builder; #...
tokio
rust
async_runtime
uds_datagram.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] use tokio::io::ReadBuf; use tokio::net::UnixDatagram; use tokio::try_join; use std::future::poll_fn; use std::io; use std::sync::Arc; use std::task::Poll; async fn echo_server(socket: UnixDatagram) -> io::Result<()> { let mut recv_buf = vec![0u8;...
tokio
rust
async_runtime
net_named_pipe.rs
#![cfg(feature = "full")] #![cfg(windows)] use std::io; use std::time::Duration; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::windows::named_pipe::{ClientOptions, PipeMode, ServerOptions}; use tokio::time; use windows_sys::Win32::Foundation::{ERROR_NO_DATA, ERROR_PIPE_BUSY}; #[tokio::test] async fn t...
tokio
rust
async_runtime
fs.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi does not support file operations all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "fs" ) ))] use tokio::fs; use tokio_test::assert_ok; #[tokio::test] a...
tokio
rust
async_runtime
process_smoke.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi/Miri cannot run system commands use tokio::process::Command; use tokio_test::assert_ok; #[tokio::test] async fn simple() { let mut cmd; if cfg!(windows) { cmd = Command::new("cmd"); cmd.arg("...
tokio
rust
async_runtime
macros_join.rs
#![cfg(feature = "macros")] #![allow(clippy::disallowed_names)] use std::sync::Arc; #[cfg(all(target_family = "wasm", target_os = "unknown"))] #[cfg(target_pointer_width = "64")] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bin...
tokio
rust
async_runtime
tcp_peek.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support peeking use tokio::io::AsyncReadExt; use tokio::net::TcpStream; use tokio_test::assert_ok; use std::thread; use std::{io::Write, net}; #[tokio::test] async fn peek() { let listener = net::TcpListener::bind...
tokio
rust
async_runtime
io_async_read.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::AsyncRead; #[test] fn assert_obj_safe() { fn _assert<T>() {} _assert::<Box<dyn AsyncRead>>(); }
tokio
rust
async_runtime
signal_multi_rt.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No `sigaction` on Miri. mod support { pub mod signal; } use support::signal::send_signal; use tokio::runtime::Runtime; use tokio::signal::unix::{signal, SignalKind}; use std::sync::mpsc::channel; use std::thread; #[test] fn...
tokio
rust
async_runtime
time_panic.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi doesn't support panic recovery all(target_os = "emscripten", feature = "rt", feature = "time") ))] #![cfg(panic = "unwind")] use futures::future; use std::error::Error; use std::time::Duration; use tokio::runtime::{B...
tokio
rust
async_runtime
net_lookup_host.rs
// WASIp1 doesn't support direct socket operations #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), ))] use tokio::net; use tokio_test::assert_ok; use std::io; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAdd...
tokio
rust
async_runtime
task_yield_now.rs
#![cfg(all( any( feature = "full", all(target_os = "emscripten", feature = "rt", feature = "macros") ), not(target_os = "wasi"), tokio_unstable ))] use tokio::task; use tokio_test::task::spawn; // `yield_now` is tested within the runtime in `rt_common`. #[test] fn yield_now_outside_of_...
tokio
rust
async_runtime
io_split.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi does not support panic recovery all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{ split, AsyncRead, AsyncReadExt, As...
tokio
rust
async_runtime
signal_realtime.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(any(target_os = "linux", target_os = "illumos"))] #![cfg(not(miri))] // No `sigaction` in Miri. mod support { pub mod signal; } use libc::c_int; use support::signal::send_signal; use futures::stream::{FuturesUnordered, StreamExt}; use std::collections::...
tokio
rust
async_runtime
fs_file_join_error.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use std::future::Future; use std::io::SeekFrom::Start; use std::path::Path; use std::task::Context; use std::time::Duration; use tokio::fs::File; use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt}; use tokio::runtime::{Builder, Handle}; fn poll_once<F: Fu...
tokio
rust
async_runtime
rt_basic.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all(target_os = "emscripten", feature = "rt", feature = "macros") ))] use tokio::runtime::{self, Runtime}; use tokio::sync::oneshot; use tokio::time::{timeout, Duration}; use tokio_test::{assert_err, assert_ok}; use std::future::Future; use std::pin::Pi...
tokio
rust
async_runtime
signal_twice.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No `sigaction` on Miri. mod support { pub mod signal; } use support::signal::send_signal; use tokio::signal::unix::{signal, SignalKind}; #[tokio::test] async fn twice() { let kind = SignalKind::user_defined1(); let m...
tokio
rust
async_runtime
macros_pin.rs
#![cfg(feature = "macros")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] use tokio::test as maybe_tokio_test; async fn one() {} async fn two() {} #[maybe_tokio_test] async fn m...
tokio
rust
async_runtime
io_read_int.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::io::ErrorKind; use tokio::io::AsyncReadExt; macro_rules! number { ($name:ident, $read:ident, $value:expr, $byte...
tokio
rust
async_runtime
sync_emscripten_blocking.rs
#![cfg(all( target_os = "emscripten", not(target_feature = "atomics"), feature = "sync" ))] use std::panic::{catch_unwind, AssertUnwindSafe}; extern "C" { /// Emscripten's `ASYNCIFY` build mode; 2 is JSPI. fn emscripten_has_asyncify() -> i32; fn emscripten_async_call( func: extern "C"...
tokio
rust
async_runtime
dump.rs
#![cfg(all( tokio_unstable, feature = "taskdump", target_os = "linux", any( target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64", target_arch = "s390x" ) ))] use std::hint::black_box; use tokio::runtime::{self, Handle}; #[inline(never)] async fn a() ...
tokio
rust
async_runtime
fs_uring_cancel_open.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use futures::future::FutureExt; use std::fs; use std::future::poll_fn; use std::task::Poll; use tempfile::NamedTempFile; use tokio_test::assert_pending; use crate::support::io_uring::{assert_f...
tokio
rust
async_runtime
sync_rwlock.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_family = "wasm...
tokio
rust
async_runtime
io_sink.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::io::IoSlice; use tokio::io::{AsyncWrite, AsyncWriteExt}; #[tokio::test] async fn sink_poll_write_is_cooperative() {...
tokio
rust
async_runtime
join_handle_panic.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi doesn't support panic recovery all(target_os = "emscripten", feature = "rt", feature = "macros", feature = "time") ))] #![cfg(panic = "unwind")] struct PanicsOnDrop; impl Drop for PanicsOnDrop { fn drop(&mut sel...
tokio
rust
async_runtime
sync_broadcast.rs
#![allow(clippy::cognitive_complexity)] #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use tokio::sync::broadcast; use tokio_test::task; use tokio_test::{ assert_err, assert_ok, assert_pending, asser...
tokio
rust
async_runtime
sync_mpsc_weak.rs
#![allow(clippy::redundant_clone)] #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::{Acquire, Release}; use tokio::sync::mpsc::{self, ch...
tokio
rust
async_runtime
tcp_into_split.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support multithreading or peeking use std::io::{Error, Result}; use std::io::{Read, Write}; use std::{net, thread}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_...
tokio
rust
async_runtime
sync_watch.rs
#![allow(clippy::cognitive_complexity)] #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use tokio::sync::watch; use tokio_test::task::spawn; use tokio_test::{ assert_pending, assert_ready, assert_read...
tokio
rust
async_runtime
net_unix_pipe.rs
#![cfg(feature = "full")] #![cfg(unix)] use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::unix::pipe; use tokio_test::task; use tokio_test::{assert_err, assert_ok, assert_pending, assert_ready_ok}; use std::fs::File; use std::io; use std::os::fd::AsFd; use std::os::unix::fs::OpenOptionsExt; use ...
tokio
rust
async_runtime
task_trace_wake.rs
#![cfg(all( tokio_unstable, feature = "taskdump", target_os = "linux", any( target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64", target_arch = "s390x" ) ))] use std::future::Future; use std::pin::Pin; use std::sync::atomic::{AtomicBool, AtomicUsize, ...
tokio
rust
async_runtime
sync_notify_owned.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; use tokio::sync::Notify; use tokio_test::task::spawn; use tokio_test::*; #[allow(unused)] trait AssertSend: Send + Sync {} impl AssertS...
tokio
rust
async_runtime
tcp_shutdown.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support multithreading use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot::channel; use tokio_test::assert_ok; #[tokio::test] async fn shutdown() { ...
tokio
rust
async_runtime
udp.rs
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind // No UDP sockets on miri. #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), not(miri) ))] use std::future::poll_fn; use std::io; use std::sync::Arc; us...
tokio
rust
async_runtime
io_write_all.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio_test::assert_ok; use tokio_test::io::Builder; use bytes::BytesMut; use...
tokio
rust
async_runtime
fs_uring_completed_then_dropped_before_repoll.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] mod support { pub(crate) mod io_uring; } use std::fmt::Debug; use std::fs; use std::future::Future; use std::path::PathBuf; use std::pin::Pin; use std::task::{Context, Poll}; use std::time...
tokio
rust
async_runtime
io_async_fd.rs
#![warn(rust_2018_idioms)] #![cfg(all(unix, feature = "full"))] use std::os::unix::io::{AsRawFd, RawFd}; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, }; use std::time::Duration; use std::{ future::Future, io::{self, ErrorKind, Read, Write}, os::fd::OwnedFd, task::{Context, Waker}, }; ...
tokio
rust
async_runtime
leaked_buffers.rs
/// Can create buffers of arbitrary lifetime. /// Frees created buffers when dropped. /// /// This struct is of course unsafe and the fact that /// it must outlive the created slices has to be ensured by /// the programmer. /// /// Used at certain test scenarios as a safer version of /// Vec::leak, to satisfy the addre...
tokio
rust
async_runtime
panic.rs
use std::panic; use std::sync::{Arc, Mutex}; pub fn test_panic<Func: FnOnce() + panic::UnwindSafe>(func: Func) -> Option<String> { static PANIC_MUTEX: Mutex<()> = Mutex::new(()); { let _guard = PANIC_MUTEX.lock(); let panic_file: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None)); ...
tokio
rust
async_runtime
signal.rs
pub fn send_signal(signal: libc::c_int) { use libc::{getpid, kill}; unsafe { let pid = getpid(); assert_eq!( kill(pid, signal), 0, "kill(pid = {}, {}) failed with error: {}", pid, signal, std::io::Error::last_os_error(), ...
tokio
rust
async_runtime
mpsc_stream.rs
#![allow(dead_code)] use std::pin::Pin; use std::task::{Context, Poll}; use tokio::sync::mpsc::{self, Receiver, Sender, UnboundedReceiver, UnboundedSender}; use tokio_stream::Stream; struct UnboundedStream<T> { recv: UnboundedReceiver<T>, } impl<T> Stream for UnboundedStream<T> { type Item = T; fn poll_ne...
tokio
rust
async_runtime
io_uring.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use std::{ fs, time::{Duration, Instant}, }; use io_uring::IoUring; // Currently, we are running some of the tests on Kernels where io_uring is not supported // to check if the fallba...
tokio
rust
async_runtime
io_vec.rs
use std::io::IoSlice; use std::ops::Deref; use std::slice; pub struct IoBufs<'a, 'b>(&'b mut [IoSlice<'a>]); impl<'a, 'b> IoBufs<'a, 'b> { pub fn new(slices: &'b mut [IoSlice<'a>]) -> Self { IoBufs(slices) } pub fn is_empty(&self) -> bool { self.0.is_empty() } pub fn advance(mut ...
tokio
rust
async_runtime
lib.rs
#![allow( clippy::cognitive_complexity, clippy::large_enum_variant, clippy::module_inception, clippy::needless_doctest_main )] #![warn( missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub )] #![deny(unused_must_use, unsafe_op_in_unsafe_fn)] #![doc(test( no_...
tokio
rust
async_runtime
blocking.rs
cfg_rt! { #[cfg(not(target_os = "emscripten"))] pub(crate) use crate::runtime::spawn_blocking; cfg_io_blocking! { #[cfg(not(target_os = "emscripten"))] #[allow(unused_imports)] pub(crate) use crate::runtime::spawn_mandatory_blocking; } #[cfg(not(target_os = "emscripten"))] ...
tokio
rust
async_runtime
addr.rs
use std::future; use std::io; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; /// Converts or resolves without blocking to one or more `SocketAddr` values. /// /// # DNS /// /// Implementations of `ToSocketAddrs` for string types require a DNS lookup. /// /// # Calling /// /// Curre...
tokio
rust
async_runtime
lookup_host.rs
cfg_net! { use crate::net::addr::{self, ToSocketAddrs}; use std::io; use std::net::SocketAddr; /// Performs a DNS resolution. /// /// The returned iterator may not actually yield any values depending on the /// outcome of any resolution performed. /// /// This API is not intended t...
tokio
rust
async_runtime
mod.rs
#![cfg(not(loom))] mod addr; cfg_not_wasip1! { #[cfg(feature = "net")] pub(crate) use addr::to_socket_addrs; } pub use addr::ToSocketAddrs; cfg_net! { mod lookup_host; pub use lookup_host::lookup_host; pub mod tcp; pub use tcp::listener::TcpListener; pub use tcp::stream::TcpStream; c...
tokio
rust
async_runtime
udp.rs
use crate::io::{Interest, PollEvented, ReadBuf, Ready}; use crate::net::{to_socket_addrs, ToSocketAddrs}; use crate::util::check_socket_for_blocking; use std::fmt; use std::io; use std::net::{self, Ipv4Addr, Ipv6Addr, SocketAddr}; use std::task::{ready, Context, Poll}; cfg_io_util! { use bytes::BufMut; } cfg_net...
tokio
rust
async_runtime
stream.rs
use crate::io::{AsyncRead, AsyncWrite, Interest, PollEvented, ReadBuf, Ready}; use crate::net::unix::split::{split, ReadHalf, WriteHalf}; use crate::net::unix::split_owned::{split_owned, OwnedReadHalf, OwnedWriteHalf}; use crate::net::unix::ucred::{self, UCred}; use crate::net::unix::SocketAddr; use crate::util::check_...
tokio
rust
async_runtime
ucred.rs
use crate::net::unix; /// Credentials of a process. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct UCred { /// PID (process ID) of the process. pid: Option<unix::pid_t>, /// UID (user ID) of the process. uid: unix::uid_t, /// GID (group ID) of the process. gid: unix::gid_t, } im...
tokio
rust
async_runtime
pipe.rs
use crate::io::interest::Interest; use crate::io::{AsyncRead, AsyncWrite, PollEvented, ReadBuf, Ready}; use mio::unix::pipe as mio_pipe; use std::fs::File; use std::io::{self, Read, Write}; use std::os::unix::fs::OpenOptionsExt; use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; ...
tokio
rust
async_runtime
mod.rs
// This module does not currently provide any public API, but it was // unintentionally defined as a public module. Hide it from the documentation // instead of changing it to a private module to avoid breakage. #[doc(hidden)] pub mod datagram; pub(crate) mod listener; pub(crate) mod socket; mod permissions; pub use...
tokio
rust
async_runtime
listener.rs
use crate::io::{Interest, PollEvented}; use crate::net::unix::{SocketAddr, UnixStream}; use crate::util::check_socket_for_blocking; use std::fmt; use std::io; #[cfg(target_os = "android")] use std::os::android::net::SocketAddrExt; #[cfg(target_os = "linux")] use std::os::linux::net::SocketAddrExt; #[cfg(any(target_os ...
tokio
rust
async_runtime
socket.rs
use std::io; use std::path::Path; use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(any(target_os = "linux", target_os = "android"))] use crate::net::unix::Permissions; use crate::net::{UnixDatagram, UnixListener, UnixStream}; cfg_net_unix! { /// A Unix socket that has not y...
tokio
rust
async_runtime
split_owned.rs
use crate::io::{AsyncRead, AsyncWrite, Interest, ReadBuf, Ready}; use crate::net::UnixStream; use crate::net::unix::SocketAddr; use std::error::Error; use std::net::Shutdown; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use std::{fmt, io}; cfg_io_util! { use bytes::BufMut; } /// Owned r...
tokio
rust
async_runtime
permissions.rs
use crate::net::unix; /// Permissions for a [`UnixSocket`]. /// /// Unlike [`std::fs::Permissions`], which can hold other platform-specific /// state, this type holds only mode bits. /// /// [`UnixSocket`]: crate::net::UnixSocket #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct Permissions { mode: uni...
tokio
rust
async_runtime
socketaddr.rs
use std::fmt; use std::path::Path; /// An address associated with a Tokio Unix socket. /// /// This type is a thin wrapper around [`std::os::unix::net::SocketAddr`]. You /// can convert to and from the standard library `SocketAddr` type using the /// [`From`] trait. #[derive(Clone)] pub struct SocketAddr(pub(super) st...
tokio
rust
async_runtime
split.rs
use crate::io::{AsyncRead, AsyncWrite, Interest, ReadBuf, Ready}; use crate::net::UnixStream; use crate::net::unix::SocketAddr; use std::io; use std::net::Shutdown; use std::pin::Pin; use std::task::{Context, Poll}; cfg_io_util! { use bytes::BufMut; } /// Borrowed read half of a [`UnixStream`], created by [`spli...
tokio
rust
async_runtime
socket.rs
use crate::io::{Interest, PollEvented, ReadBuf, Ready}; use crate::net::unix::SocketAddr; use crate::util::check_socket_for_blocking; use std::fmt; use std::io; use std::net::Shutdown; use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use std::os::unix::net; use std::path::Path; use std:...
tokio
rust
async_runtime
stream.rs
cfg_not_wasi! { use std::time::Duration; } cfg_not_wasip1! { use crate::net::{to_socket_addrs, ToSocketAddrs}; use std::future::poll_fn; } use crate::io::{AsyncRead, AsyncWrite, Interest, PollEvented, ReadBuf, Ready}; use crate::net::tcp::split::{split, ReadHalf, WriteHalf}; use crate::net::tcp::split_own...
tokio
rust
async_runtime
listener.rs
use crate::io::{Interest, PollEvented}; use crate::net::tcp::TcpStream; use crate::util::check_socket_for_blocking; cfg_not_wasip1! { use crate::net::{to_socket_addrs, ToSocketAddrs}; } use std::fmt; use std::io; use std::net::{self, SocketAddr}; use std::task::{ready, Context, Poll}; cfg_net! { /// A TCP so...
tokio
rust
async_runtime
socket.rs
use crate::net::{TcpListener, TcpStream}; use std::fmt; use std::io; use std::net::SocketAddr; #[cfg(not(windows))] use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use std::time::Duration; cfg_windows! { use crate::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket,...
tokio
rust
async_runtime
split_owned.rs
use crate::io::{AsyncRead, AsyncWrite, Interest, ReadBuf, Ready}; use crate::net::TcpStream; use std::error::Error; use std::future::poll_fn; use std::net::{Shutdown, SocketAddr}; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use std::{fmt, io}; cfg_io_util! { use bytes::BufMut; } /// Ow...
tokio
rust
async_runtime
split.rs
use crate::io::{AsyncRead, AsyncWrite, Interest, ReadBuf, Ready}; use crate::net::TcpStream; use std::future::poll_fn; use std::io; use std::net::{Shutdown, SocketAddr}; use std::pin::Pin; use std::task::{Context, Poll}; cfg_io_util! { use bytes::BufMut; } /// Borrowed read half of a [`TcpStream`], created by [`...
tokio
rust
async_runtime
named_pipe.rs
use std::ffi::c_void; use std::ffi::OsStr; use std::io::{self, Read, Write}; use std::pin::Pin; use std::ptr; use std::ptr::null_mut; use std::task::{Context, Poll}; use crate::io::{AsyncRead, AsyncWrite, Interest, PollEvented, ReadBuf, Ready}; use crate::os::windows::io::{ AsHandle, AsRawHandle, BorrowedHandle, F...
tokio
rust
async_runtime
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>...
tokio
rust
async_runtime
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. #![expect(unsafe_op_in_unsafe_fn)] use c...
tokio
rust
async_runtime
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....
tokio
rust
async_runtime
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...
tokio
rust
async_runtime
blocking_check.rs
#[cfg(unix)] use std::os::fd::AsFd; #[cfg(unix)] #[allow(unused_variables)] #[track_caller] pub(crate) fn check_socket_for_blocking<S: AsFd>(s: &S) -> crate::io::Result<()> { #[cfg(not(tokio_allow_from_blocking_fd))] { let sock = socket2::SockRef::from(s); debug_assert!( sock.nonbl...
tokio
rust
async_runtime
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::...
tokio
rust
async_runtime
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 ...
tokio
rust
async_runtime
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...
tokio
rust
async_runtime
wake.rs
use crate::loom::sync::Arc; use std::marker::PhantomData; use std::mem::ManuallyDrop; use std::ops::Deref; use std::task::{RawWaker, RawWakerVTable, Waker}; /// Simplified waking interface based on Arcs. pub(crate) trait Wake: Send + Sync + Sized + 'static { /// Wake by value. fn wake(arc_self: Arc<Self>); ...
tokio
rust
async_runtime
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...
tokio
rust
async_runtime
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>...
tokio
rust
async_runtime
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...
tokio
rust
async_runtime
ptr_expose.rs
use std::marker::PhantomData; #[cfg(miri)] use {crate::loom::sync::Mutex, std::collections::BTreeMap}; pub(crate) struct PtrExposeDomain<T> { #[cfg(miri)] map: Mutex<BTreeMap<usize, *const T>>, _phantom: PhantomData<T>, } // SAFETY: Actually using the pointers is unsafe, so it's sound to transfer them acr...
tokio
rust
async_runtime
wake_list.rs
use core::mem::MaybeUninit; use core::ptr; use std::task::Waker; const NUM_WAKERS: usize = 32; /// A list of wakers to be woken. /// /// # Invariants /// /// The first `curr` elements of `inner` are initialized. pub(crate) struct WakeList { inner: [MaybeUninit<Waker>; NUM_WAKERS], curr: usize, } impl WakeLis...
tokio
rust
async_runtime
sharded_list.rs
use std::ptr::NonNull; use std::sync::atomic::Ordering; use crate::loom::sync::{Mutex, MutexGuard}; use crate::util::metric_atomics::{MetricAtomicU64, MetricAtomicUsize}; use super::linked_list::{Link, LinkedList}; /// An intrusive linked list supporting highly concurrent updates. /// /// It currently relies on `Lin...
tokio
rust
async_runtime
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...
tokio
rust
async_runtime
memchr.rs
#[cfg(not(all(unix, feature = "libc")))] fn memchr_inner(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.iter().position(|val| needle == *val) } #[cfg(all(unix, feature = "libc"))] fn memchr_inner(needle: u8, haystack: &[u8]) -> Option<usize> { let start = haystack.as_ptr(); // SAFETY: `start` is...
tokio
rust
async_runtime
bit.rs
use std::fmt; #[derive(Clone, Copy, PartialEq)] pub(crate) struct Pack { mask: usize, shift: u32, } impl Pack { /// Value is packed in the `width` least-significant bits. pub(crate) const fn least_significant(width: u32) -> Pack { let mask = mask_for(width); Pack { mask, shift: 0 } ...
tokio
rust
async_runtime
idle_notified_set.rs
use std::marker::PhantomPinned; use std::mem::ManuallyDrop; use std::ptr::NonNull; use std::task::{Context, Waker}; use crate::loom::cell::UnsafeCell; use crate::loom::sync::{Arc, Mutex}; use crate::util::linked_list::{self, Link, LinkedList}; use crate::util::{waker_ref, Wake}; /// This is the main handle to the col...
tokio
rust
async_runtime
rand.rs
cfg_rt! { mod rt; pub(crate) use rt::RngSeedGenerator; } /// 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)] #[derive(Clone, Debug)] pub struct RngSeed { s: u32, ...