repo stringclasses 7
values | lang stringclasses 2
values | aspect stringclasses 7
values | file stringlengths 5 48 | content stringlengths 283 144k |
|---|---|---|---|---|
tokio | rust | async_runtime | mod.rs | cfg_rt! {
pub use crate::runtime::task::{JoinError, JoinHandle};
mod blocking;
pub use blocking::spawn_blocking;
mod spawn;
pub use spawn::spawn;
cfg_rt_multi_thread! {
pub use blocking::block_in_place;
}
mod yield_now;
pub use yield_now::yield_now;
pub mod coop;
... |
tokio | rust | async_runtime | spawn.rs | use crate::runtime::AutoBox;
use crate::task::JoinHandle;
use crate::util::trace::SpawnMeta;
use std::future::Future;
cfg_rt! {
/// Spawns a new asynchronous task, returning a
/// [`JoinHandle`] for it.
///
/// The provided future will start running in the background immediately
/// when `spawn` i... |
tokio | rust | async_runtime | blocking.rs | use crate::task::JoinHandle;
cfg_rt_multi_thread! {
/// Runs the provided blocking function on the current thread without
/// blocking the executor.
///
/// In general, issuing a blocking call or performing a lot of compute in a
/// future without yielding is problematic, as it may prevent the exec... |
tokio | rust | async_runtime | builder.rs | #![allow(unreachable_pub)]
use crate::{
runtime::{AutoBox, Handle},
task::{JoinHandle, LocalSet},
util::trace::SpawnMeta,
};
use std::{future::Future, io, mem};
/// Factory which is used to configure the properties of a new task.
///
/// **Note**: This is an [unstable API][unstable]. The public API of this... |
tokio | rust | async_runtime | consume_budget.rs | /// Consumes a unit of budget and returns the execution back to the Tokio
/// runtime *if* the task's coop budget was exhausted.
///
/// The task will only yield if its entire coop budget has been exhausted.
/// This function can be used in order to insert optional yield points into long
/// computations that do not us... |
tokio | rust | async_runtime | unconstrained.rs | use pin_project_lite::pin_project;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
pin_project! {
/// Future for the [`unconstrained`](unconstrained) method.
#[cfg_attr(docsrs, doc(cfg(feature = "rt")))]
#[must_use = "Unconstrained does nothing unless polled"]
pub struct Unc... |
tokio | rust | async_runtime | mod.rs | #![cfg_attr(not(feature = "full"), allow(dead_code))]
#![cfg_attr(not(feature = "rt"), allow(unreachable_pub))]
cfg_rt! {
mod consume_budget;
pub use consume_budget::consume_budget;
mod unconstrained;
pub use unconstrained::{unconstrained, Unconstrained};
}
// ```ignore
// # use tokio_stream::{Strea... |
tokio | rust | async_runtime | os.rs | /// Platform-specific extensions to `std` for Windows.
///
/// See [`std::os::windows`](https://doc.rust-lang.org/std/os/windows/index.html).
pub mod windows {
/// Windows-specific extensions to general I/O primitives.
///
/// See [`std::os::windows::io`](https://doc.rust-lang.org/std/os/windows/io/index.ht... |
tokio | rust | async_runtime | mod.rs | /// The name of a type which is not defined here.
///
/// This is typically used as an alias for another type, like so:
///
/// ```rust,ignore
/// /// See [some::other::location](https://example.com).
/// type DEFINED_ELSEWHERE = crate::doc::NotDefinedHere;
/// ```
///
/// This type is uninhabitable like the [`never` t... |
tokio | rust | async_runtime | notify.rs | // Allow `unreachable_pub` warnings when sync is not enabled
// due to the usage of `Notify` within the `rt` feature set.
// When this module is compiled with `sync` enabled we will warn on
// this lint. When `rt` is enabled we use `pub(crate)` which
// triggers this warning but it is safe to ignore in this case.
#![cf... |
tokio | rust | async_runtime | once_cell.rs | use super::{Semaphore, SemaphorePermit, TryAcquireError};
use crate::loom::cell::UnsafeCell;
use std::error::Error;
use std::fmt;
use std::future::Future;
use std::mem::MaybeUninit;
use std::ops::Drop;
use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering};
// This file contains an implementation of an OnceCell. ... |
tokio | rust | async_runtime | set_once.rs | use super::Notify;
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::AtomicBool;
use std::error::Error;
use std::fmt;
use std::future::{poll_fn, Future};
use std::mem::MaybeUninit;
use std::ops::Drop;
use std::ptr;
use std::sync::atomic::Ordering;
use std::task::Poll;
// This file contains an impleme... |
tokio | rust | async_runtime | oneshot.rs | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Arc;
#[cfg(all(tokio_unstable, feature = "tracing"))]
use crate::util::trace;
use std::fmt;
use std::future::Future;
use std::mem::MaybeUninit;
... |
tokio | rust | async_runtime | semaphore.rs | use super::batch_semaphore as ll; // low level implementation
use super::{AcquireError, TryAcquireError};
#[cfg(all(tokio_unstable, feature = "tracing"))]
use crate::util::trace;
use std::sync::Arc;
/// Counting semaphore performing asynchronous permit acquisition.
///
/// A semaphore maintains a set of permits. Permi... |
tokio | rust | async_runtime | barrier.rs | use crate::loom::sync::Mutex;
use crate::sync::watch;
#[cfg(all(tokio_unstable, feature = "tracing"))]
use crate::util::trace;
/// A barrier enables multiple tasks to synchronize the beginning of some computation.
///
/// ```
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// use tokio::sync::... |
tokio | rust | async_runtime | batch_semaphore.rs | #![cfg_attr(not(feature = "sync"), allow(unreachable_pub, dead_code))]
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::{Mutex, MutexGuard};
use crate::util::linked_list::{self, LinkedList};
#[cfg(all(tokio_unstable, feature = "tracing"))]
use crate::util::trace;
use... |
tokio | rust | async_runtime | rwlock.rs | use crate::sync::batch_semaphore::{Semaphore, TryAcquireError};
use crate::sync::mutex::TryLockError;
#[cfg(all(tokio_unstable, feature = "tracing"))]
use crate::util::trace;
use std::cell::UnsafeCell;
use std::marker;
use std::marker::PhantomData;
use std::sync::Arc;
pub(crate) mod owned_read_guard;
pub(crate) mod ow... |
tokio | rust | async_runtime | mod.rs | #![cfg_attr(loom, allow(dead_code, unreachable_pub, unused_imports))]
cfg_sync! {
/// Named future types.
pub mod futures {
pub use super::notify::{Notified, OwnedNotified};
}
mod barrier;
pub use barrier::{Barrier, BarrierWaitResult};
pub mod broadcast;
pub mod mpsc;
mod m... |
tokio | rust | async_runtime | mutex.rs | #![cfg_attr(not(feature = "sync"), allow(unreachable_pub, dead_code))]
use crate::sync::batch_semaphore as semaphore;
#[cfg(all(tokio_unstable, feature = "tracing"))]
use crate::util::trace;
use std::cell::UnsafeCell;
use std::error::Error;
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
use std::sync:... |
tokio | rust | async_runtime | watch.rs | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
use crate::sync::notify::Notify;
use crate::task::coop::cooperative;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::atomic::Ordering::{AcqRel, Relaxed};
use crate::loom::sync::{Arc, RwLock, RwLockReadGuard};
use std::fmt;
use ... |
tokio | rust | async_runtime | broadcast.rs | use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::{AtomicBool, AtomicUsize};
use crate::loom::sync::{Arc, Mutex, MutexGuard};
use crate::task::coop::cooperative;
use crate::util::linked_list::{self, GuardedLinkedList, LinkedList};
use crate::util::WakeList;
use std::fmt;
use std::future::Future;
use st... |
tokio | rust | async_runtime | owned_write_guard.rs | use crate::sync::rwlock::owned_read_guard::OwnedRwLockReadGuard;
use crate::sync::rwlock::owned_write_guard_mapped::OwnedRwLockMappedWriteGuard;
use crate::sync::rwlock::RwLock;
use std::marker::PhantomData;
use std::sync::Arc;
use std::{fmt, mem, ops, ptr};
/// Owned RAII structure used to release the exclusive write... |
tokio | rust | async_runtime | owned_read_guard.rs | use crate::sync::rwlock::RwLock;
use std::marker::PhantomData;
use std::sync::Arc;
use std::{fmt, mem, ops, ptr};
/// Owned RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read_owned`] method on
/// [`RwLock`].
///
/// [`read_owned`]: method@... |
tokio | rust | async_runtime | write_guard_mapped.rs | use crate::sync::batch_semaphore::Semaphore;
use std::marker::PhantomData;
use std::{fmt, mem, ops};
/// RAII structure used to release the exclusive write access of a lock when
/// dropped.
///
/// This structure is created by [mapping] an [`RwLockWriteGuard`]. It is a
/// separate type from `RwLockWriteGuard` to dis... |
tokio | rust | async_runtime | write_guard.rs | use crate::sync::batch_semaphore::Semaphore;
use crate::sync::rwlock::read_guard::RwLockReadGuard;
use crate::sync::rwlock::write_guard_mapped::RwLockMappedWriteGuard;
use std::marker::PhantomData;
use std::{fmt, mem, ops};
/// RAII structure used to release the exclusive write access of a lock when
/// dropped.
///
/... |
tokio | rust | async_runtime | read_guard.rs | use crate::sync::batch_semaphore::Semaphore;
use std::marker::PhantomData;
use std::{fmt, mem, ops};
/// RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read`] method on
/// [`RwLock`].
///
/// [`read`]: method@crate::sync::RwLock::read
/// [... |
tokio | rust | async_runtime | owned_write_guard_mapped.rs | use crate::sync::rwlock::RwLock;
use std::marker::PhantomData;
use std::sync::Arc;
use std::{fmt, mem, ops, ptr};
/// Owned RAII structure used to release the exclusive write access of a lock when
/// dropped.
///
/// This structure is created by [mapping] an [`OwnedRwLockWriteGuard`]. It is a
/// separate type from `... |
tokio | rust | async_runtime | notify.rs | use crate::sync::Notify;
use std::future::Future;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTable... |
tokio | rust | async_runtime | loom_oneshot.rs | use crate::sync::oneshot;
use loom::future::block_on;
use loom::thread;
use std::future::poll_fn;
use std::pin::Pin;
use std::task::Poll::{Pending, Ready};
#[test]
fn smoke() {
loom::model(|| {
let (tx, rx) = oneshot::channel();
thread::spawn(move || {
tx.send(1).unwrap();
});... |
tokio | rust | async_runtime | loom_atomic_waker.rs | use crate::sync::task::AtomicWaker;
use loom::future::block_on;
use loom::sync::atomic::AtomicUsize;
use loom::thread;
use std::future::poll_fn;
use std::sync::atomic::Ordering::Relaxed;
use std::sync::Arc;
use std::task::Poll::{Pending, Ready};
struct Chan {
num: AtomicUsize,
task: AtomicWaker,
}
#[test]
fn... |
tokio | rust | async_runtime | loom_set_once.rs | use crate::sync::SetOnce;
use loom::future::block_on;
use loom::sync::atomic::AtomicU32;
use loom::thread;
use std::sync::atomic::Ordering;
use std::sync::Arc;
#[derive(Clone)]
struct DropCounter {
pub drops: Arc<AtomicU32>,
}
impl DropCounter {
pub fn new() -> Self {
Self {
drops: Arc::n... |
tokio | rust | async_runtime | loom_watch.rs | use crate::sync::watch;
use loom::future::block_on;
use loom::thread;
use std::sync::Arc;
#[test]
fn smoke() {
loom::model(|| {
let (tx, mut rx1) = watch::channel(1);
let mut rx2 = rx1.clone();
let mut rx3 = rx1.clone();
let mut rx4 = rx1.clone();
let mut rx5 = rx1.clone();... |
tokio | rust | async_runtime | semaphore_batch.rs | use crate::sync::batch_semaphore::Semaphore;
use tokio_test::*;
const MAX_PERMITS: usize = crate::sync::Semaphore::MAX_PERMITS;
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn poll_acquire_one_available() {
let s = Semaphore::new(100);
a... |
tokio | rust | async_runtime | mod.rs | cfg_not_loom! {
mod atomic_waker;
mod notify;
mod semaphore_batch;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_batch;
mod loom_watch;
mod loom_rwlock;
mod loom_set_once;
... |
tokio | rust | async_runtime | loom_rwlock.rs | use crate::sync::rwlock::*;
use loom::future::block_on;
use loom::thread;
use std::sync::Arc;
#[test]
fn concurrent_write() {
let b = loom::model::Builder::new();
b.check(|| {
let rwlock = Arc::new(RwLock::<u32>::new(0));
let rwclone = rwlock.clone();
let t1 = thread::spawn(move || {... |
tokio | rust | async_runtime | loom_mpsc.rs | use crate::sync::mpsc::{self, BLOCK_CAP};
use loom::future::block_on;
use loom::sync::Arc;
use loom::thread;
use std::future::poll_fn;
use tokio_test::assert_ok;
#[test]
fn closing_tx() {
loom::model(|| {
let (tx, mut rx) = mpsc::channel(16);
thread::spawn(move || {
tx.try_send(()).un... |
tokio | rust | async_runtime | loom_list.rs | use crate::sync::mpsc::list;
use loom::thread;
use std::sync::Arc;
#[test]
fn smoke() {
use crate::sync::mpsc::block::Read;
const NUM_TX: usize = 2;
const NUM_MSG: usize = 2;
loom::model(|| {
let (tx, mut rx) = list::channel();
let tx = Arc::new(tx);
for th in 0..NUM_TX {
... |
tokio | rust | async_runtime | atomic_waker.rs | use crate::sync::AtomicWaker;
use tokio_test::task;
use std::task::Waker;
#[allow(unused)]
trait AssertSend: Send {}
#[allow(unused)]
trait AssertSync: Sync {}
impl AssertSend for AtomicWaker {}
impl AssertSync for AtomicWaker {}
impl AssertSend for Waker {}
impl AssertSync for Waker {}
#[cfg(all(target_family = ... |
tokio | rust | async_runtime | loom_broadcast.rs | use crate::sync::broadcast;
use crate::sync::broadcast::error::RecvError::{Closed, Lagged};
use loom::future::block_on;
use loom::sync::Arc;
use loom::thread;
use tokio_test::{assert_err, assert_ok};
#[test]
fn broadcast_send() {
loom::model(|| {
let (tx1, mut rx) = broadcast::channel(2);
let tx1 ... |
tokio | rust | async_runtime | loom_notify.rs | use crate::sync::Notify;
use loom::future::block_on;
use loom::sync::Arc;
use loom::thread;
use tokio_test::{assert_pending, assert_ready};
/// `util::wake_list::NUM_WAKERS`
const WAKE_LIST_SIZE: usize = 32;
#[test]
fn notify_one() {
loom::model(|| {
let tx = Arc::new(Notify::new());
let rx = tx... |
tokio | rust | async_runtime | loom_semaphore_batch.rs | use crate::sync::batch_semaphore::*;
use loom::future::block_on;
use loom::sync::atomic::AtomicUsize;
use loom::thread;
use std::future::{poll_fn, Future};
use std::pin::Pin;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::Arc;
use std::task::Poll::Ready;
use std::task::{Context, Poll};
#[test]
fn basic_usage... |
tokio | rust | async_runtime | atomic_waker.rs | #![cfg_attr(any(loom, not(feature = "sync")), allow(dead_code, unreachable_pub))]
use crate::loom::cell::UnsafeCell;
use crate::loom::hint;
use crate::loom::sync::atomic::AtomicUsize;
use std::fmt;
use std::panic::{resume_unwind, AssertUnwindSafe, RefUnwindSafe, UnwindSafe};
use std::sync::atomic::Ordering::{AcqRel, ... |
tokio | rust | async_runtime | unbounded.rs | use crate::loom::sync::{atomic::AtomicUsize, Arc};
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the [`unbounded_channel`] function.
pub struct ... |
tokio | rust | async_runtime | chan.rs | use crate::loom::cell::UnsafeCell;
use crate::loom::future::AtomicWaker;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Arc;
use crate::runtime::park::CachedParkThread;
use crate::sync::mpsc::error::TryRecvError;
use crate::sync::mpsc::{bounded, list, unbounded};
use crate::sync::notify::Notify;
use... |
tokio | rust | async_runtime | error.rs | use std::error::Error;
use std::fmt;
/// Error returned by [`Sender::send`](super::Sender::send).
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct SendError<T>(pub T);
impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SendError").finish_non_ex... |
tokio | rust | async_runtime | list.rs | use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
use crate::loom::thread;
use crate::sync::mpsc::block::{self, Block};
use std::fmt;
use std::ptr::NonNull;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
/// List queue transmit handle.
pub(crate) struct Tx<T> {
/// Tail in the `Block... |
tokio | rust | async_runtime | bounded.rs | use crate::loom::sync::Arc;
use crate::sync::batch_semaphore::{self as semaphore, TryAcquireError};
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError, TrySendError};
cfg_time! {
use crate::sync::mpsc::error::SendTimeoutError;
use crate::time::Duration;
}
use std::fmt;
use std... |
tokio | rust | async_runtime | mod.rs | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
pub(super) mod block;
mod bounded;
pub use self::bounded::{
channel, OwnedPermit, Permit, PermitIterator, Receiver, Sender, WeakSender,
};
mod chan;
pub(super) mod list;
mod unbounded;
pub use self::unbounded::{
unbounded_channel, Unbo... |
tokio | rust | async_runtime | block.rs | use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
use std::alloc::Layout;
use std::mem::MaybeUninit;
use std::ops;
use std::ptr::{self, NonNull};
use std::sync::atomic::Ordering::{self, AcqRel, Acquire, Release};
/// A block in a linked list.
///
/// Each block in the list ca... |
tokio | rust | async_runtime | copy.rs | use crate::fs::asyncify;
use std::path::Path;
/// Copies the contents of one file to another. This function will also copy the permission bits
/// of the original file to the destination file.
/// This function will overwrite the contents of to.
///
/// This is the async equivalent of [`std::fs::copy`].
///
/// # Exam... |
tokio | rust | async_runtime | symlink_metadata.rs | use crate::fs::asyncify;
use std::fs::Metadata;
use std::io;
use std::path::Path;
/// Queries the file system metadata for a path.
///
/// This is an async version of [`std::fs::symlink_metadata`][std]
///
/// [std]: fn@std::fs::symlink_metadata
pub async fn symlink_metadata(path: impl AsRef<Path>) -> io::Result<Meta... |
tokio | rust | async_runtime | read_uring.rs | use crate::fs::OpenOptions;
use crate::runtime::driver::op::Op;
use std::io;
use std::io::ErrorKind;
use std::os::fd::OwnedFd;
use std::path::Path;
// this algorithm is inspired from rust std lib version 1.90.0
// https://doc.rust-lang.org/1.90.0/src/std/io/mod.rs.html#409
const PROBE_SIZE: usize = 32;
const PROBE_SI... |
tokio | rust | async_runtime | try_exists.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Returns `Ok(true)` if the path points at an existing entity.
///
/// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `Ok(false)`.
///
/// This is the async e... |
tokio | rust | async_runtime | file_times.rs | use std::time::SystemTime;
#[cfg(target_vendor = "apple")]
use std::os::darwin::fs::FileTimesExt;
#[cfg(windows)]
use std::os::windows::fs::FileTimesExt;
/// Timestamps for a file.
///
/// This is a specialized version of [`std::fs::FileTimes`] for usage with
/// [`File::set_times`](crate::fs::File::set_times). Unlik... |
tokio | rust | async_runtime | hard_link.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Creates a new hard link on the filesystem.
///
/// This is an async version of [`std::fs::hard_link`].
///
/// The `link` path will be a link pointing to the `original` path. Note that systems
/// often require these two paths to both be located on the sa... |
tokio | rust | async_runtime | metadata.rs | use crate::fs::asyncify;
use std::fs::Metadata;
use std::io;
use std::path::Path;
/// Given a path, queries the file system to get information about a file,
/// directory, etc.
///
/// This is an async version of [`std::fs::metadata`].
///
/// This function will traverse symbolic links to query information about the
... |
tokio | rust | async_runtime | symlink_file.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Creates a new file symbolic link on the filesystem.
///
/// The `link` path will be a file symbolic link pointing to the `original`
/// path.
///
/// This is an async version of [`std::os::windows::fs::symlink_file`][std]
///
/// [std]: https://doc.rust-l... |
tokio | rust | async_runtime | rename.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Renames a file or directory to a new name, replacing the original file if
/// `to` already exists.
///
/// This will not work if the new name is on a different mount point.
///
/// This is an async version of [`std::fs::rename`].
pub async fn rename(from:... |
tokio | rust | async_runtime | write.rs | use crate::{fs::asyncify, util::as_ref::OwnedBuf};
use std::{io, path::Path};
/// Creates a future that will open a file for writing and write the entire
/// contents of `contents` to it.
///
/// This is the async equivalent of [`std::fs::write`][std].
///
/// This operation is implemented by running the equivalent b... |
tokio | rust | async_runtime | create_dir_all.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Recursively creates a directory and all of its parent components if they
/// are missing.
///
/// This is an async version of [`std::fs::create_dir_all`].
///
/// # Platform-specific behavior
///
/// This function currently corresponds to the `mkdir` func... |
tokio | rust | async_runtime | symlink.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Creates a new symbolic link on the filesystem.
///
/// The `link` path will be a symbolic link pointing to the `original` path.
///
/// This is an async version of [`std::os::unix::fs::symlink`].
pub async fn symlink(original: impl AsRef<Path>, link: impl... |
tokio | rust | async_runtime | symlink_dir.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Creates a new directory symlink on the filesystem.
///
/// The `link` path will be a directory symbolic link pointing to the `original`
/// path.
///
/// This is an async version of [`std::os::windows::fs::symlink_dir`][std]
///
/// [std]: https://doc.rus... |
tokio | rust | async_runtime | dir_builder.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// A builder for creating directories in various manners.
///
/// This is a specialized version of [`std::fs::DirBuilder`] for usage on
/// the Tokio runtime.
#[derive(Debug, Default)]
pub struct DirBuilder {
/// Indicates whether to create parent direct... |
tokio | rust | async_runtime | mod.rs | #![cfg(not(loom))]
mod canonicalize;
pub use self::canonicalize::canonicalize;
mod create_dir;
pub use self::create_dir::create_dir;
mod create_dir_all;
pub use self::create_dir_all::create_dir_all;
mod dir_builder;
pub use self::dir_builder::DirBuilder;
mod file;
pub use self::file::File;
mod file_times;
pub us... |
tokio | rust | async_runtime | read_to_string.rs | use crate::fs::asyncify;
use std::{io, path::Path};
/// Creates a future which will open a file for reading and read the entire
/// contents into a string and return said string.
///
/// This is the async equivalent of [`std::fs::read_to_string`][std].
///
/// This operation is implemented by running the equivalent b... |
tokio | rust | async_runtime | read.rs | use crate::fs::asyncify;
use std::{io, path::Path};
/// Reads the entire contents of a file into a bytes vector.
///
/// This is an async version of [`std::fs::read`].
///
/// This is a convenience function for using [`File::open`] and [`read_to_end`]
/// with fewer imports and without an intermediate variable. It pr... |
tokio | rust | async_runtime | remove_file.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Removes a file from the filesystem.
///
/// Note that there is no guarantee that the file is immediately deleted (e.g.
/// depending on platform, other open file descriptors may prevent immediate
/// removal).
///
/// This is an async version of [`std::fs... |
tokio | rust | async_runtime | open_options.rs | use crate::fs::{asyncify, File};
use std::io;
use std::path::Path;
cfg_io_uring! {
mod uring_open_options;
pub(crate) use uring_open_options::UringOpenOptions;
}
#[cfg(test)]
mod mock_open_options;
#[cfg(test)]
use mock_open_options::MockOpenOptions as StdOpenOptions;
#[cfg(not(test))]
use std::fs::OpenOpti... |
tokio | rust | async_runtime | read_dir.rs | use crate::fs::asyncify;
use std::collections::VecDeque;
use std::ffi::OsString;
use std::fs::{FileType, Metadata};
use std::future::Future;
use std::io;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::sync::Arc;
use std::task::{ready, Context, Poll};
#[cfg(test)]
use super::mocks::spawn_blocking;
#[cfg(t... |
tokio | rust | async_runtime | canonicalize.rs | use crate::fs::asyncify;
use std::io;
use std::path::{Path, PathBuf};
/// Returns the canonical, absolute form of a path with all intermediate
/// components normalized and symbolic links resolved.
///
/// This is an async version of [`std::fs::canonicalize`].
///
/// # Platform-specific behavior
///
/// This functio... |
tokio | rust | async_runtime | create_dir.rs | use crate::fs::asyncify;
use std::io;
use std::path::Path;
/// Creates a new, empty directory at the provided path.
///
/// This is an async version of [`std::fs::create_dir`].
///
/// # Platform-specific behavior
///
/// This function currently corresponds to the `mkdir` function on Unix
/// and the `CreateDirectory... |
tokio | rust | async_runtime | set_permissions.rs | use crate::fs::asyncify;
use std::fs::Permissions;
use std::io;
use std::path::Path;
/// Changes the permissions found on a file or a directory.
///
/// This is an async version of [`std::fs::set_permissions`][std]
///
/// [std]: fn@std::fs::set_permissions
pub async fn set_permissions(path: impl AsRef<Path>, perm: P... |
tokio | rust | async_runtime | file.rs | use crate::fs::{asyncify, FileTimes, OpenOptions};
use crate::io::blocking::{Buf, DEFAULT_MAX_BUF_SIZE};
use crate::io::{AsyncRead, AsyncSeek, AsyncWrite, ReadBuf};
use crate::sync::Mutex;
use std::cmp;
use std::fmt;
use std::fs::{Metadata, Permissions};
use std::future::Future;
use std::io::{self, Seek, SeekFrom};
us... |
tokio | rust | async_runtime | uring_open_options.rs | use std::{io, os::unix::fs::OpenOptionsExt};
#[cfg(test)]
use super::mock_open_options::MockOpenOptions as StdOpenOptions;
#[cfg(not(test))]
use std::fs::OpenOptions as StdOpenOptions;
#[derive(Debug, Clone)]
pub(crate) struct UringOpenOptions {
pub(crate) read: bool,
pub(crate) write: bool,
pub(crate) ap... |
tokio | rust | async_runtime | block_on.rs | use std::future::Future;
cfg_rt! {
#[track_caller]
pub(crate) fn block_on<F: Future>(f: F) -> F::Output {
let mut e = crate::runtime::context::try_enter_blocking_region().expect(
"Cannot block the current thread from within a runtime. This \
happens because a function attempted ... |
tokio | rust | async_runtime | mod.rs | #![cfg_attr(not(feature = "macros"), allow(unreachable_pub))]
#[cfg(any(feature = "macros", feature = "process"))]
pub(crate) mod maybe_done;
cfg_process! {
mod try_join;
pub(crate) use try_join::try_join3;
}
cfg_sync! {
mod block_on;
pub(crate) use block_on::block_on;
}
cfg_trace! {
mod trace;... |
tokio | rust | async_runtime | maybe_done.rs | use pin_project_lite::pin_project;
use std::future::{Future, IntoFuture};
use std::pin::Pin;
use std::task::{ready, Context, Poll};
pin_project! {
/// A future that may have completed.
#[derive(Debug)]
#[project = MaybeDoneProj]
#[project_replace = MaybeDoneProjReplace]
#[repr(C)] // https://github... |
tokio | rust | async_runtime | try_join.rs | use crate::future::maybe_done::{maybe_done, MaybeDone};
use pin_project_lite::pin_project;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
pub(crate) fn try_join3<T1, F1, T2, F2, T3, F3, E>(
future1: F1,
future2: F2,
future3: F3,
) -> TryJoin3<F1, F2, F3>
where
F1: Future<O... |
tokio | rust | async_runtime | registry.rs | use crate::signal::unix::{OsExtraData, OsStorage};
use crate::sync::watch;
use std::ops;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::OnceLock;
pub(crate) type EventId = usize;
/// State for a specific event, whether a notification is pending delivery,
/// and what listeners are registered.
#[derive... |
tokio | rust | async_runtime | reusable_box.rs | use std::alloc::Layout;
use std::future::Future;
use std::panic::AssertUnwindSafe;
use std::pin::Pin;
use std::ptr::{self, NonNull};
use std::task::{Context, Poll};
use std::{fmt, panic};
/// A reusable `Pin<Box<dyn Future<Output = T> + Send>>`.
///
/// This type lets you replace the future stored in the box without
/... |
tokio | rust | async_runtime | unix.rs | #![cfg(unix)]
#![cfg_attr(docsrs, doc(cfg(all(unix, feature = "signal"))))]
use crate::runtime::scheduler;
use crate::runtime::signal::Handle;
use crate::signal::registry::{globals, EventId, EventInfo, Globals, Storage};
use crate::signal::RxFuture;
use crate::sync::watch;
use mio::net::UnixStream;
use std::io::{self... |
tokio | rust | async_runtime | mod.rs | use crate::sync::watch::Receiver;
use std::task::{Context, Poll};
#[cfg(feature = "signal")]
mod ctrl_c;
#[cfg(feature = "signal")]
pub use ctrl_c::ctrl_c;
#[cfg(unix)]
pub(crate) mod registry;
pub mod unix;
pub mod windows;
mod reusable_box;
use self::reusable_box::ReusableBoxFuture;
#[derive(Debug)]
struct RxFut... |
tokio | rust | async_runtime | ctrl_c.rs | #[cfg(unix)]
use super::unix::{self as os_impl};
#[cfg(windows)]
use super::windows::{self as os_impl};
use std::io;
/// Completes when a "ctrl-c" notification is sent to the process.
///
/// While signals are handled very differently between Unix and Windows, both
/// platforms support receiving a signal on "ctrl-c"... |
tokio | rust | async_runtime | windows.rs | #![cfg(any(windows, docsrs))]
#![cfg_attr(docsrs, doc(cfg(all(windows, feature = "signal"))))]
use crate::signal::RxFuture;
use std::io;
use std::task::{Context, Poll};
#[cfg(windows)]
#[path = "windows/sys.rs"]
mod imp;
// For building documentation on Unix machines when the `docsrs` flag is set.
#[cfg(not(windows)... |
tokio | rust | async_runtime | stub.rs | use crate::signal::RxFuture;
use std::io;
pub(super) fn ctrl_break() -> io::Result<RxFuture> {
panic!()
}
pub(super) fn ctrl_close() -> io::Result<RxFuture> {
panic!()
}
pub(super) fn ctrl_c() -> io::Result<RxFuture> {
panic!()
}
pub(super) fn ctrl_logoff() -> io::Result<RxFuture> {
panic!()
}
pub(... |
tokio | rust | async_runtime | sys.rs | use std::io;
use std::io::Error;
use std::ops::Index;
use std::sync::OnceLock;
use crate::signal::RxFuture;
use crate::sync::watch;
use windows_sys::core::BOOL;
use windows_sys::Win32::System::Console as console;
type EventInfo = watch::Sender<()>;
#[derive(Clone, Copy)]
#[repr(u32)]
enum SignalKind {
CtrlC = c... |
tokio | rust | async_runtime | atomic_usize.rs | use std::cell::UnsafeCell;
use std::fmt;
use std::ops;
use std::panic;
/// `AtomicUsize` providing an additional `unsync_load` function.
pub(crate) struct AtomicUsize {
inner: UnsafeCell<std::sync::atomic::AtomicUsize>,
}
unsafe impl Send for AtomicUsize {}
unsafe impl Sync for AtomicUsize {}
impl panic::RefUnwin... |
tokio | rust | async_runtime | barrier.rs | use crate::loom::sync::{Condvar, Mutex};
use std::fmt;
use std::time::{Duration, Instant};
/// A barrier enables multiple threads to synchronize the beginning
/// of some computation.
///
/// # Examples
///
/// ```
/// # #[cfg(not(target_family = "wasm"))]
/// # {
/// use std::sync::{Arc, Barrier};
/// use std::thread... |
tokio | rust | async_runtime | atomic_u64.rs | // `AtomicU64` can only be used on targets with `target_has_atomic` is 64 or greater.
// Once `cfg_target_has_atomic` feature is stable, we can replace it with
// `#[cfg(target_has_atomic = "64")]`.
// Refs: https://github.com/rust-lang/rust/tree/master/src/librustc_target
cfg_has_atomic_u64! {
#[path = "atomic_u64... |
tokio | rust | async_runtime | rwlock.rs | use std::sync::{self, RwLockReadGuard, RwLockWriteGuard, TryLockError};
/// Adapter for `std::sync::RwLock` that removes the poisoning aspects
/// from its api.
#[derive(Debug)]
pub(crate) struct RwLock<T: ?Sized>(sync::RwLock<T>);
#[allow(dead_code)]
impl<T> RwLock<T> {
#[inline]
pub(crate) fn new(t: T) -> S... |
tokio | rust | async_runtime | atomic_u32.rs | use std::cell::UnsafeCell;
use std::fmt;
use std::ops::Deref;
use std::panic;
/// `AtomicU32` providing an additional `unsync_load` function.
pub(crate) struct AtomicU32 {
inner: UnsafeCell<std::sync::atomic::AtomicU32>,
}
unsafe impl Send for AtomicU32 {}
unsafe impl Sync for AtomicU32 {}
impl panic::RefUnwindSa... |
tokio | rust | async_runtime | atomic_u16.rs | use std::cell::UnsafeCell;
use std::fmt;
use std::ops::Deref;
use std::panic;
/// `AtomicU16` providing an additional `unsync_load` function.
pub(crate) struct AtomicU16 {
inner: UnsafeCell<std::sync::atomic::AtomicU16>,
}
unsafe impl Send for AtomicU16 {}
unsafe impl Sync for AtomicU16 {}
impl panic::RefUnwindSa... |
tokio | rust | async_runtime | unsafe_cell.rs | #[derive(Debug)]
pub(crate) struct UnsafeCell<T>(std::cell::UnsafeCell<T>);
impl<T> UnsafeCell<T> {
pub(crate) const fn new(data: T) -> UnsafeCell<T> {
UnsafeCell(std::cell::UnsafeCell::new(data))
}
#[inline(always)]
pub(crate) fn with<R>(&self, f: impl FnOnce(*const T) -> R) -> R {
f(... |
tokio | rust | async_runtime | mod.rs | #![cfg_attr(any(not(feature = "full"), loom), allow(unused_imports, dead_code))]
mod atomic_u16;
mod atomic_u32;
mod atomic_u64;
mod atomic_usize;
mod barrier;
mod mutex;
#[cfg(all(feature = "parking_lot", not(miri)))]
mod parking_lot;
mod rwlock;
mod unsafe_cell;
pub(crate) mod cell {
pub(crate) use super::unsaf... |
tokio | rust | async_runtime | atomic_u64_as_mutex.rs | use crate::loom::sync::Mutex;
use std::sync::atomic::Ordering;
cfg_has_const_mutex_new! {
#[path = "atomic_u64_static_const_new.rs"]
mod static_macro;
}
cfg_not_has_const_mutex_new! {
#[path = "atomic_u64_static_once_cell.rs"]
mod static_macro;
}
pub(crate) use static_macro::StaticAtomicU64;
#[deriv... |
tokio | rust | async_runtime | mutex.rs | use std::sync::{self, MutexGuard, TryLockError};
/// Adapter for `std::Mutex` that removes the poisoning aspects
/// from its API.
#[derive(Debug)]
pub(crate) struct Mutex<T: ?Sized>(sync::Mutex<T>);
#[allow(dead_code)]
impl<T> Mutex<T> {
#[inline]
pub(crate) fn new(t: T) -> Mutex<T> {
Mutex(sync::Mut... |
tokio | rust | async_runtime | atomic_u64_static_once_cell.rs | use super::AtomicU64;
use crate::loom::sync::{atomic::Ordering, Mutex};
use std::sync::OnceLock;
pub(crate) struct StaticAtomicU64 {
init: u64,
cell: OnceLock<Mutex<u64>>,
}
impl AtomicU64 {
pub(crate) fn new(val: u64) -> Self {
Self {
inner: Mutex::new(val),
}
}
}
impl St... |
tokio | rust | async_runtime | parking_lot.rs | use std::fmt;
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
use std::sync::{LockResult, TryLockError};
use std::time::Duration;
// All types in this file are marked with PhantomData to ensure that
// parking_lot's send_guard feature does not leak through and affect when Tokio
// types are Send.
//
// ... |
tokio | rust | async_runtime | mod.rs | #[path = "unix/mod.rs"]
#[cfg(unix)]
mod imp;
#[cfg(unix)]
pub(crate) mod unix {
pub(crate) use super::imp::*;
}
#[path = "windows.rs"]
#[cfg(windows)]
mod imp;
mod kill;
use crate::io::{AsyncRead, AsyncWrite, ReadBuf};
use crate::process::kill::Kill;
use std::ffi::OsStr;
use std::future::Future;
use std::io;
... |
tokio | rust | async_runtime | windows.rs | use crate::io::{blocking::Blocking, AsyncRead, AsyncWrite, ReadBuf};
use crate::process::kill::Kill;
use crate::process::SpawnedChild;
use crate::sync::oneshot;
use std::fmt;
use std::fs::File as StdFile;
use std::future::Future;
use std::io;
use std::os::windows::prelude::{AsRawHandle, IntoRawHandle, OwnedHandle, Raw... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.