id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/src/runtime/driver.rs:1 | //! Abstracts out the entire chain of runtime sub-drivers into common types.
use crate::park::{Park, ParkThread};
use std::io;
use std::time::Duration;
// ===== io driver =====
cfg_io_driver! {
type IoDriver = crate::park::Either<crate::io::driver::Driver, crate::park::ParkThread>;
pub(crate) type IoHandle = ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | a1d0681cd2e581b1f6767126858d2f3d5d8992f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a1d0681cd2e581b1f6767126858d2f3d5d8992f5/tokio/src/runtime/driver.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:2 | macro_rules! cfg_signal_internal_and_unix {
($($item:item)*) => {
#[cfg(unix)]
cfg_signal_internal! { $($item)* }
}
}
cfg_signal_internal_and_unix! {
type SignalDriver = crate::park::Either<crate::signal::unix::driver::Driver, IoDriver>;
pub(crate) type SignalHandle = Option<crate::sign... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | a1d0681cd2e581b1f6767126858d2f3d5d8992f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a1d0681cd2e581b1f6767126858d2f3d5d8992f5/tokio/src/runtime/driver.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:3 | pub(crate) type Clock = crate::time::Clock;
pub(crate) type TimeHandle = Option<crate::time::driver::Handle>;
fn create_clock() -> Clock {
crate::time::Clock::new()
}
fn create_time_driver(
enable: bool,
signal_driver: SignalDriver,
clock: Clock,
) -> (TimeDriver, T... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | a1d0681cd2e581b1f6767126858d2f3d5d8992f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a1d0681cd2e581b1f6767126858d2f3d5d8992f5/tokio/src/runtime/driver.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:4 | (signal_driver, ())
}
}
// ===== runtime driver =====
#[derive(Debug)]
pub(crate) struct Driver {
inner: TimeDriver,
}
pub(crate) struct Resources {
pub(crate) io_handle: IoHandle,
pub(crate) signal_handle: SignalHandle,
pub(crate) time_handle: TimeHandle,
pub(crate) clock: Clock,
}
pub(crat... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | a1d0681cd2e581b1f6767126858d2f3d5d8992f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a1d0681cd2e581b1f6767126858d2f3d5d8992f5/tokio/src/runtime/driver.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:5 | ))
}
}
impl Park for Driver {
type Unpark = <TimeDriver as Park>::Unpark;
type Error = <TimeDriver as Park>::Error;
fn unpark(&self) -> Self::Unpark {
self.inner.unpark()
}
fn park(&mut self) -> Result<(), Self::Error> {
self.inner.park()
}
fn park_timeout(&mut self, ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | a1d0681cd2e581b1f6767126858d2f3d5d8992f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a1d0681cd2e581b1f6767126858d2f3d5d8992f5/tokio/src/runtime/driver.rs | 161 | 184 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:1 | //! Abstracts out the entire chain of runtime sub-drivers into common types.
use crate::park::{Park, ParkThread};
use std::io;
use std::time::Duration;
// ===== io driver =====
cfg_io_driver! {
type IoDriver = crate::park::Either<crate::io::driver::Driver, crate::park::ParkThread>;
pub(crate) type IoHandle = ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | 7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb/tokio/src/runtime/driver.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:2 | macro_rules! cfg_unix_and_signal {
($($item:item)*) => {
$(
#[cfg(all(not(loom), unix, feature = "signal"))]
$item
)*
}
}
macro_rules! cfg_neither_unix_nor_windows {
($($item:item)*) => {
$(
#[cfg(any(loom, not(all(unix, feature = "signal"))))]
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | 7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb/tokio/src/runtime/driver.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:3 | pub(crate) type SignalHandle = ();
fn create_signal_driver(io_driver: IoDriver) -> io::Result<(SignalDriver, SignalHandle)> {
Ok((io_driver, ()))
}
}
// ===== time driver =====
cfg_time! {
type TimeDriver = crate::park::Either<crate::time::driver::Driver<SignalDriver>, SignalDriver>;
pub(cra... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | 7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb/tokio/src/runtime/driver.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:4 | pub(crate) type Clock = ();
pub(crate) type TimeHandle = ();
fn create_clock() -> Clock {
()
}
fn create_time_driver(
_enable: bool,
signal_driver: SignalDriver,
_clock: Clock,
) -> (TimeDriver, TimeHandle) {
(signal_driver, ())
}
}
// ===== runtime dri... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | 7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb/tokio/src/runtime/driver.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/driver.rs:5 | let (signal_driver, signal_handle) = create_signal_driver(io_driver)?;
let (time_driver, time_handle) =
create_time_driver(cfg.enable_time, signal_driver, clock.clone());
Ok((
Self { inner: time_driver },
Resources {
io_handle,
signal_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/runtime/driver.rs | MIT | 7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb/tokio/src/runtime/driver.rs | 161 | 196 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:1 | use crate::io::blocking::Buf;
use crate::io::uring::open::Open;
use crate::io::uring::read::Read;
use crate::io::uring::utils::ArcFd;
use crate::io::uring::write::Write;
use crate::runtime::Handle;
use io_uring::cqueue;
use io_uring::squeue::Entry;
use std::future::Future;
use std::io::{self, Error};
use std::mem;
us... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/driver/op.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:2 | // so `#[allow(dead_code)]` is needed.
#[allow(dead_code)] CancelData,
),
/// The operation has completed with a single cqe result
Completed(io_uring::cqueue::Entry),
}
pub(crate) enum State {
Initialize(Option<Entry>),
Polled(usize),
Complete,
}
pub(crate) struct Op<T: Cancellable> {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/driver/op.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:3 | impl<T: Cancellable> Drop for Op<T> {
fn drop(&mut self) {
match self.state {
// We've already dropped this Op.
State::Complete => (),
// We will cancel this Op.
State::Polled(index) => {
let data = self.take_data();
let handle ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/driver/op.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:4 | // This is used when you want to terminate an operation with an error.
//
// The `Op` type that implements this trait can return the passed error
// upstream by embedding it in the `Output`.
fn complete_with_error(self, error: Error) -> Self::Output;
}
/// Extracts the `CancelData` needed to safely can... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/driver/op.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:5 | };
Poll::Pending
}
State::Polled(idx) => {
let mut ctx = driver.get_uring().lock();
let lifecycle = ctx.ops.get_mut(*idx).expect("Lifecycle must be present");
match mem::replace(lifecycle, Lifecycle::Submitted) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/driver/op.rs | 161 | 212 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:6 | Lifecycle::Cancelled(_) => {
unreachable!("Cancelled lifecycle should never be seen here");
}
}
}
State::Complete => {
panic!("Future polled after completion");
}
}
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/driver/op.rs | 201 | 212 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:1 | use crate::io::uring::open::Open;
use crate::io::uring::read::Read;
use crate::io::uring::write::Write;
use crate::runtime::Handle;
use io_uring::cqueue;
use io_uring::squeue::Entry;
use std::future::Future;
use std::io::{self, Error};
use std::mem;
use std::pin::Pin;
use std::task::{Context, Poll, Waker};
// This fi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 398eef81203865c3033cdb0e88c637ec7ff0dd65 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/398eef81203865c3033cdb0e88c637ec7ff0dd65/tokio/src/runtime/driver/op.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:2 | Completed(io_uring::cqueue::Entry),
}
pub(crate) enum State {
Initialize(Option<Entry>),
Polled(usize),
Complete,
}
pub(crate) struct Op<T: Cancellable> {
// Handle to the runtime
handle: Handle,
// State of this Op
state: State,
// Per operation data.
data: Option<T>,
}
impl<T: C... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 398eef81203865c3033cdb0e88c637ec7ff0dd65 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/398eef81203865c3033cdb0e88c637ec7ff0dd65/tokio/src/runtime/driver/op.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:3 | State::Complete => (),
// We will cancel this Op.
State::Polled(index) => {
let data = self.take_data();
let handle = &mut self.handle;
handle.inner.driver().io().cancel_op(index, data);
}
// This Op has not been polled yet.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 398eef81203865c3033cdb0e88c637ec7ff0dd65 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/398eef81203865c3033cdb0e88c637ec7ff0dd65/tokio/src/runtime/driver/op.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:4 | fn complete_with_error(self, error: Error) -> Self::Output;
}
/// Extracts the `CancelData` needed to safely cancel an in-flight io_uring operation.
pub(crate) trait Cancellable {
fn cancel(self) -> CancelData;
}
impl<T: Cancellable> Unpin for Op<T> {}
impl<T: Cancellable + Completable + Send> Future for Op<T> {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 398eef81203865c3033cdb0e88c637ec7ff0dd65 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/398eef81203865c3033cdb0e88c637ec7ff0dd65/tokio/src/runtime/driver/op.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:5 | State::Polled(idx) => {
let mut ctx = driver.get_uring().lock();
let lifecycle = ctx.ops.get_mut(*idx).expect("Lifecycle must be present");
match mem::replace(lifecycle, Lifecycle::Submitted) {
// Only replace the stored waker if it wouldn't wake the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 398eef81203865c3033cdb0e88c637ec7ff0dd65 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/398eef81203865c3033cdb0e88c637ec7ff0dd65/tokio/src/runtime/driver/op.rs | 161 | 207 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:1 | use crate::io::uring::open::Open;
use crate::io::uring::write::Write;
use crate::runtime::Handle;
use io_uring::cqueue;
use io_uring::squeue::Entry;
use std::future::Future;
use std::io::{self, Error};
use std::mem;
use std::pin::Pin;
use std::task::{Context, Poll, Waker};
// This field isn't accessed directly, but i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db/tokio/src/runtime/driver/op.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:2 | pub(crate) enum State {
Initialize(Option<Entry>),
Polled(usize),
Complete,
}
pub(crate) struct Op<T: Cancellable> {
// Handle to the runtime
handle: Handle,
// State of this Op
state: State,
// Per operation data.
data: Option<T>,
}
impl<T: Cancellable> Op<T> {
/// # Safety
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db/tokio/src/runtime/driver/op.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:3 | State::Polled(index) => {
let data = self.take_data();
let handle = &mut self.handle;
handle.inner.driver().io().cancel_op(index, data);
}
// This Op has not been polled yet.
// We don't need to do anything here.
State::Init... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db/tokio/src/runtime/driver/op.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:4 | /// Extracts the `CancelData` needed to safely cancel an in-flight io_uring operation.
pub(crate) trait Cancellable {
fn cancel(self) -> CancelData;
}
impl<T: Cancellable> Unpin for Op<T> {}
impl<T: Cancellable + Completable + Send> Future for Op<T> {
type Output = T::Output;
fn poll(self: Pin<&mut Self>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db/tokio/src/runtime/driver/op.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:5 | let lifecycle = ctx.ops.get_mut(*idx).expect("Lifecycle must be present");
match mem::replace(lifecycle, Lifecycle::Submitted) {
// Only replace the stored waker if it wouldn't wake the new one
Lifecycle::Waiting(prev) if !prev.will_wake(cx.waker()) => {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a709e391bdab3cf8bab9fe65d75fa2b92f4e0db/tokio/src/runtime/driver/op.rs | 161 | 205 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:1 | use crate::io::uring::open::Open;
use crate::io::uring::write::Write;
use crate::runtime::Handle;
use io_uring::cqueue;
use io_uring::squeue::Entry;
use std::future::Future;
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;
use std::task::Waker;
use std::{io, mem};
// This field isn't accessed directly, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 3698a6f153c3b3484a5231901aae441e39327768 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3698a6f153c3b3484a5231901aae441e39327768/tokio/src/runtime/driver/op.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:3 | State::Polled(index) => {
let data = self.take_data();
let handle = &mut self.handle;
handle.inner.driver().io().cancel_op(index, data);
}
// This Op has not been polled yet.
// We don't need to do anything here.
State::Init... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 3698a6f153c3b3484a5231901aae441e39327768 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3698a6f153c3b3484a5231901aae441e39327768/tokio/src/runtime/driver/op.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:4 | impl<T: Cancellable> Unpin for Op<T> {}
impl<T: Cancellable + Completable + Send> Future for Op<T> {
type Output = io::Result<T::Output>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut();
let handle = &mut this.handle;
let driver = h... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 3698a6f153c3b3484a5231901aae441e39327768 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3698a6f153c3b3484a5231901aae441e39327768/tokio/src/runtime/driver/op.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:5 | this.state = State::Complete;
drop(ctx);
let data = this
.take_data()
.expect("Data must be present on completion");
Poll::Ready(data.complete(cqe.into()))
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 3698a6f153c3b3484a5231901aae441e39327768 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3698a6f153c3b3484a5231901aae441e39327768/tokio/src/runtime/driver/op.rs | 161 | 187 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:1 | use crate::io::uring::open::Open;
use crate::runtime::Handle;
use io_uring::cqueue;
use io_uring::squeue::Entry;
use std::future::Future;
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;
use std::task::Waker;
use std::{io, mem};
#[derive(Debug)]
pub(crate) enum CancelData {
Open(
// This fie... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 3e84a198e4d6283f015965cd627ee5aaff69e022 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e84a198e4d6283f015965cd627ee5aaff69e022/tokio/src/runtime/driver/op.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:2 | pub(crate) enum State {
Initialize(Option<Entry>),
Polled(usize),
Complete,
}
pub(crate) struct Op<T: Cancellable> {
// Handle to the runtime
handle: Handle,
// State of this Op
state: State,
// Per operation data.
data: Option<T>,
}
impl<T: Cancellable> Op<T> {
/// # Safety
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 3e84a198e4d6283f015965cd627ee5aaff69e022 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e84a198e4d6283f015965cd627ee5aaff69e022/tokio/src/runtime/driver/op.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:3 | let data = self.take_data();
let handle = &mut self.handle;
handle.inner.driver().io().cancel_op(index, data);
}
// This Op has not been polled yet.
// We don't need to do anything here.
State::Initialize(_) => (),
}
}
}
/// A ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 3e84a198e4d6283f015965cd627ee5aaff69e022 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e84a198e4d6283f015965cd627ee5aaff69e022/tokio/src/runtime/driver/op.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:4 | impl<T: Cancellable + Completable + Send> Future for Op<T> {
type Output = io::Result<T::Output>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut();
let handle = &mut this.handle;
let driver = handle.inner.driver().io();
match... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 3e84a198e4d6283f015965cd627ee5aaff69e022 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e84a198e4d6283f015965cd627ee5aaff69e022/tokio/src/runtime/driver/op.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:1 | use crate::runtime::Handle;
use io_uring::cqueue;
use io_uring::squeue::Entry;
use std::future::Future;
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;
use std::task::Waker;
use std::{io, mem};
#[derive(Debug)]
pub(crate) enum CancelData {}
#[derive(Debug)]
pub(crate) enum Lifecycle {
/// The oper... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 9f848c9f544a87f52ca406bad895a2b0ffa10e4b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f848c9f544a87f52ca406bad895a2b0ffa10e4b/tokio/src/runtime/driver/op.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:2 | state: State,
// Per operation data.
data: Option<T>,
}
impl<T: Cancellable> Op<T> {
/// # Safety
///
/// Callers must ensure that parameters of the entry (such as buffer) are valid and will
/// be valid for the entire duration of the operation, otherwise it may cause memory problems.
#[all... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 9f848c9f544a87f52ca406bad895a2b0ffa10e4b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f848c9f544a87f52ca406bad895a2b0ffa10e4b/tokio/src/runtime/driver/op.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:3 | }
/// A single CQE result
pub(crate) struct CqeResult {
#[allow(dead_code)]
pub(crate) result: io::Result<u32>,
}
impl From<cqueue::Entry> for CqeResult {
fn from(cqe: cqueue::Entry) -> Self {
let res = cqe.result();
let result = if res >= 0 {
Ok(res as u32)
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 9f848c9f544a87f52ca406bad895a2b0ffa10e4b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f848c9f544a87f52ca406bad895a2b0ffa10e4b/tokio/src/runtime/driver/op.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:4 | match &mut this.state {
State::Initialize(entry_opt) => {
let entry = entry_opt.take().expect("Entry must be present");
let waker = cx.waker().clone();
// SAFETY: entry is valid for the entire duration of the operation
let idx = unsafe { driver... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 9f848c9f544a87f52ca406bad895a2b0ffa10e4b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f848c9f544a87f52ca406bad895a2b0ffa10e4b/tokio/src/runtime/driver/op.rs | 121 | 178 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:5 | }
Lifecycle::Submitted => {
unreachable!("Submitted lifecycle should never be seen here");
}
Lifecycle::Cancelled(_) => {
unreachable!("Cancelled lifecycle should never be seen here");
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 9f848c9f544a87f52ca406bad895a2b0ffa10e4b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f848c9f544a87f52ca406bad895a2b0ffa10e4b/tokio/src/runtime/driver/op.rs | 161 | 178 |
tokio-rs/tokio:tokio/src/runtime/driver/op.rs:3 | }
/// A single CQE result
pub(crate) struct CqeResult {
#[allow(dead_code)]
pub(crate) result: io::Result<u32>,
}
impl From<cqueue::Entry> for CqeResult {
fn from(cqe: cqueue::Entry) -> Self {
let res = cqe.result();
let result = if res >= 0 {
Ok(res as u32)
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/driver/op.rs | MIT | 327bec2caf92af5e2732f8fdfe2e4a20d349f67e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/327bec2caf92af5e2732f8fdfe2e4a20d349f67e/tokio/src/runtime/driver/op.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use crate::runtime::scheduler;
use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
/// Currently in a runtime context.
#[cfg_attr(not(feature = "rt"), allow(dead_code))]
Entered { allow_block_in_place: bool },
/// No... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 32da1aa9da833f6db59d6a97e2a569b780d9f6b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32da1aa9da833f6db59d6a97e2a569b780d9f6b4/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | /// executor.
#[track_caller]
pub(crate) fn enter_runtime(handle: &scheduler::Handle, allow_block_in_place: bool) -> EnterRuntimeGuard {
if let Some(enter) = try_enter_runtime(allow_block_in_place) {
// Set the current runtime handle. This should not fail. A later
// cleanup will... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 32da1aa9da833f6db59d6a97e2a569b780d9f6b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32da1aa9da833f6db59d6a97e2a569b780d9f6b4/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | })
}
}
// Forces the current "entered" state to be cleared while the closure
// is executed.
//
// # Warning
//
// This is hidden for a reason. Do not use without fully understanding
// executors. Misusing can easily cause your program to deadlock.
cfg_rt_multi_thread! {
pub(crate) fn exit_runtime<F: FnOnce() ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 32da1aa9da833f6db59d6a97e2a569b780d9f6b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32da1aa9da833f6db59d6a97e2a569b780d9f6b4/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | let reset = ENTERED.with(|c| {
if let EnterContext::Entered {
allow_block_in_place: true,
} = c.get()
{
c.set(EnterContext::Entered {
allow_block_in_place: false,
});
true
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 32da1aa9da833f6db59d6a97e2a569b780d9f6b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32da1aa9da833f6db59d6a97e2a569b780d9f6b4/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | }
}
cfg_rt! {
use crate::loom::thread::AccessError;
impl BlockingRegionGuard {
fn new() -> BlockingRegionGuard {
BlockingRegionGuard { _p: PhantomData }
}
/// Blocks the thread on the specified future, returning the value with
/// which that future completes.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 32da1aa9da833f6db59d6a97e2a569b780d9f6b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32da1aa9da833f6db59d6a97e2a569b780d9f6b4/tokio/src/runtime/enter.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:6 | let when = Instant::now() + timeout;
loop {
if let Ready(v) = crate::runtime::coop::budget(|| f.as_mut().poll(&mut cx)) {
return Ok(v);
}
let now = Instant::now();
if now >= when {
return Err(());
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 32da1aa9da833f6db59d6a97e2a569b780d9f6b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32da1aa9da833f6db59d6a97e2a569b780d9f6b4/tokio/src/runtime/enter.rs | 201 | 233 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
#[cfg_attr(not(feature = "rt"), allow(dead_code))]
Entered {
allow_block_in_place: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 467adec4e16bdf1b5461e77d87d1d56b4a29f001 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/467adec4e16bdf1b5461e77d87d1d56b4a29f001/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | current thread while the thread is being used to drive \
asynchronous tasks."
);
}
/// Tries to enter a runtime context, returns `None` if already in a runtime
/// context.
pub(crate) fn try_enter(allow_block_in_place: bool) -> Option<Enter> {
ENTERED.with(|c| {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 467adec4e16bdf1b5461e77d87d1d56b4a29f001 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/467adec4e16bdf1b5461e77d87d1d56b4a29f001/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | let e = c.get();
assert!(e.is_entered(), "asked to exit when not entered");
c.set(EnterContext::NotEntered);
e
});
let _reset = Reset(was);
// dropping _reset after f() will reset ENTERED
f()
}
}
cfg_rt! {
/// Disallows blocking in the curren... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 467adec4e16bdf1b5461e77d87d1d56b4a29f001 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/467adec4e16bdf1b5461e77d87d1d56b4a29f001/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | {
c.set(EnterContext::Entered {
allow_block_in_place: true,
});
}
})
}
}
}
}
cfg_rt_multi_thread! {
/// Returns true if in a runtime context.
pub(crate) fn context() -> EnterC... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 467adec4e16bdf1b5461e77d87d1d56b4a29f001 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/467adec4e16bdf1b5461e77d87d1d56b4a29f001/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | F: std::future::Future,
{
use crate::runtime::park::CachedParkThread;
use std::task::Context;
use std::task::Poll::Ready;
use std::time::Instant;
let mut park = CachedParkThread::new();
let waker = park.waker().map_err(|_| ())?;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 467adec4e16bdf1b5461e77d87d1d56b4a29f001 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/467adec4e16bdf1b5461e77d87d1d56b4a29f001/tokio/src/runtime/enter.rs | 161 | 205 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | {
c.set(EnterContext::Entered {
allow_block_in_place: true,
});
}
})
}
}
}
}
cfg_rt_multi_thread! {
/// Returns true if in a runtime context.
pub(crate) fn context() -> EnterC... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | a051ed726f3b99b077e8c9ef8ef1df2ab2943213 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a051ed726f3b99b077e8c9ef8ef1df2ab2943213/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | F: std::future::Future,
{
use crate::park::thread::CachedParkThread;
use std::task::Context;
use std::task::Poll::Ready;
use std::time::Instant;
let mut park = CachedParkThread::new();
let waker = park.waker().map_err(|_| ())?;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | a051ed726f3b99b077e8c9ef8ef1df2ab2943213 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a051ed726f3b99b077e8c9ef8ef1df2ab2943213/tokio/src/runtime/enter.rs | 161 | 205 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | {
c.set(EnterContext::Entered {
allow_block_in_place: true,
});
}
})
}
}
}
}
cfg_rt_multi_thread! {
/// Returns true if in a runtime context.
pub(crate) fn context() -> EnterC... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | b1f40f4356c7f7be0e1959f992608d2058a76deb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b1f40f4356c7f7be0e1959f992608d2058a76deb/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | F: std::future::Future,
{
use crate::park::thread::CachedParkThread;
use std::task::Context;
use std::task::Poll::Ready;
use std::time::Instant;
let mut park = CachedParkThread::new();
let waker = park.waker().map_err(|_| ())?;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | b1f40f4356c7f7be0e1959f992608d2058a76deb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b1f40f4356c7f7be0e1959f992608d2058a76deb/tokio/src/runtime/enter.rs | 161 | 205 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
#[cfg_attr(not(feature = "rt"), allow(dead_code))]
Entered {
allow_blocking: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(self) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 964535eab006ef7b776e644e53076493a931fbce | github | async-runtime | https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | current thread while the thread is being used to drive \
asynchronous tasks."
);
}
/// Tries to enter a runtime context, returns `None` if already in a runtime
/// context.
pub(crate) fn try_enter(allow_blocking: bool) -> Option<Enter> {
ENTERED.with(|c| {
if c.g... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 964535eab006ef7b776e644e53076493a931fbce | github | async-runtime | https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | let e = c.get();
assert!(e.is_entered(), "asked to exit when not entered");
c.set(EnterContext::NotEntered);
e
});
let _reset = Reset(was);
// dropping _reset after f() will reset ENTERED
f()
}
}
cfg_rt! {
/// Disallows blocking in the curren... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 964535eab006ef7b776e644e53076493a931fbce | github | async-runtime | https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | {
c.set(EnterContext::Entered {
allow_blocking: true,
});
}
})
}
}
}
}
cfg_rt_multi_thread! {
/// Returns true if in a runtime context.
pub(crate) fn context() -> EnterContext... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 964535eab006ef7b776e644e53076493a931fbce | github | async-runtime | https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
#[cfg_attr(not(feature = "rt"), allow(dead_code))]
Entered {
allow_blocking: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(self) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 99aa8d12b7ad2ef011a7a9f652f7455b3f175821 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
#[cfg_attr(not(feature = "rt"), allow(dead_code))]
Entered {
allow_blocking: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(self) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | "Cannot start a runtime from within a runtime. This happens \
because a function (like `block_on`) attempted to block the \
current thread while the thread is being used to drive \
asynchronous tasks."
);
}
/// Tries to enter a runtime context, returns `None` if alre... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | let was = ENTERED.with(|c| {
let e = c.get();
assert!(e.is_entered(), "asked to exit when not entered");
c.set(EnterContext::NotEntered);
e
});
let _reset = Reset(was);
// dropping _reset after f() will reset ENTERED
f()
}
}
cfg_rt! {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | allow_blocking: false,
} = c.get()
{
c.set(EnterContext::Entered {
allow_blocking: true,
});
}
})
}
}
}
}
cfg_rt_multi_thread! {
/// Return... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | F: std::future::Future,
{
use crate::park::Park;
use crate::park::thread::CachedParkThread;
use std::task::Context;
use std::task::Poll::Ready;
use std::time::Instant;
let mut park = CachedParkThread::new();
let waker = park.ge... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/runtime/enter.rs | 161 | 206 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
#[cfg_attr(not(feature = "rt"), allow(dead_code))]
Entered {
allow_blocking: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(self) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 7f92bce39f7046e204381127936e2014094f9638 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | because a function (like `block_on`) attempted to block the \
current thread while the thread is being used to drive \
asynchronous tasks."
);
}
/// Tries to enter a runtime context, returns `None` if already in a runtime
/// context.
pub(crate) fn try_enter(allow_blocki... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 7f92bce39f7046e204381127936e2014094f9638 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | let was = ENTERED.with(|c| {
let e = c.get();
assert!(e.is_entered(), "asked to exit when not entered");
c.set(EnterContext::NotEntered);
e
});
let _reset = Reset(was);
// dropping _reset after f() will reset ENTERED
f()
}
}
cfg_rt! {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 7f92bce39f7046e204381127936e2014094f9638 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | } = c.get()
{
c.set(EnterContext::Entered {
allow_blocking: true,
});
}
})
}
}
}
}
cfg_rt_multi_thread! {
/// Returns true if in a runtime context.
pub(cra... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 7f92bce39f7046e204381127936e2014094f9638 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | {
use crate::park::Park;
use crate::park::thread::CachedParkThread;
use std::task::Context;
use std::task::Poll::Ready;
use std::time::Instant;
let mut park = CachedParkThread::new();
let waker = park.get_unpark()?.into_waker();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 7f92bce39f7046e204381127936e2014094f9638 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/runtime/enter.rs | 161 | 205 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
#[cfg_attr(not(feature = "rt"), allow(dead_code))]
Entered {
allow_blocking: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(self) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | because a function (like `block_on`) attempted to block the \
current thread while the thread is being used to drive \
asynchronous tasks."
);
}
/// Tries to enter a runtime context, returns `None` if already in a runtime
/// context.
pub(crate) fn try_enter(allow_blocki... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | let was = ENTERED.with(|c| {
let e = c.get();
assert!(e.is_entered(), "asked to exit when not entered");
c.set(EnterContext::NotEntered);
e
});
let _reset = Reset(was);
// dropping _reset after f() will reset ENTERED
f()
}
}
cfg_rt! {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | because a function (like `block_on`) attempted to block the \
current thread while the thread is being used to drive \
asynchronous tasks."
);
}
/// Tries to enter a runtime context, returns `None` if already in a runtime
/// context.
pub(crate) fn try_enter(allow_blocki... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | c90681bd8e629b5fde988b9f5be7b915e5cf8ae5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
#[cfg_attr(not(feature = "rt-core"), allow(dead_code))]
Entered {
allow_blocking: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | because a function (like `block_on`) attempted to block the \
current thread while the thread is being used to drive \
asynchronous tasks."
);
}
/// Tries to enter a runtime context, returns `None` if already in a runtime
/// context.
pub(crate) fn try_enter(allow_blocki... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | let was = ENTERED.with(|c| {
let e = c.get();
assert!(e.is_entered(), "asked to exit when not entered");
c.set(EnterContext::NotEntered);
e
});
let _reset = Reset(was);
// dropping _reset after f() will reset ENTERED
f()
}
}
cfg_rt_ut... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | } = c.get()
{
c.set(EnterContext::Entered {
allow_blocking: true,
});
}
})
}
}
}
}
cfg_rt_threaded! {
/// Returns true if in a runtime context.
pub(crate) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
Entered {
#[allow(dead_code)]
allow_blocking: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(self) -> bool {
matches!(se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | b704c53b9cc76eaf8c9c6585f8444c4515d27728 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | /// Tries to enter a runtime context, returns `None` if already in a runtime
/// context.
pub(crate) fn try_enter(allow_blocking: bool) -> Option<Enter> {
ENTERED.with(|c| {
if c.get().is_entered() {
None
} else {
c.set(EnterContext::Entered { allow_blocking });
S... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | b704c53b9cc76eaf8c9c6585f8444c4515d27728 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | let _reset = Reset(was);
// dropping _reset after f() will reset ENTERED
f()
}
cfg_rt_core! {
cfg_rt_util! {
/// Disallow blocking in the current runtime context until the guard is dropped.
pub(crate) fn disallow_blocking() -> DisallowBlockingGuard {
let reset = ENTERED.with(|c|... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | b704c53b9cc76eaf8c9c6585f8444c4515d27728 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | })
}
}
}
}
}
cfg_rt_threaded! {
cfg_blocking! {
/// Returns true if in a runtime context.
pub(crate) fn context() -> EnterContext {
ENTERED.with(|c| c.get())
}
}
}
impl Enter {
/// Blocks the thread on the specified future, return... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | b704c53b9cc76eaf8c9c6585f8444c4515d27728 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | }
}
cfg_blocking_impl! {
use crate::park::ParkError;
use std::time::Duration;
impl Enter {
/// Blocks the thread on the specified future for **at most** `timeout`
///
/// If the future completes before `timeout`, the result is returned. If
/// `timeout` elapses, then `Err` ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | b704c53b9cc76eaf8c9c6585f8444c4515d27728 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/src/runtime/enter.rs | 161 | 219 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:6 | }
}
}
}
impl fmt::Debug for Enter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Enter").finish()
}
}
impl Drop for Enter {
fn drop(&mut self) {
ENTERED.with(|c| {
assert!(c.get().is_entered());
c.set(EnterContext::NotEntere... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | b704c53b9cc76eaf8c9c6585f8444c4515d27728 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/src/runtime/enter.rs | 201 | 219 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy)]
pub(crate) enum EnterContext {
Entered {
#[allow(dead_code)]
allow_blocking: bool,
},
NotEntered,
}
impl EnterContext {
pub(crate) fn is_entered(self) -> bool {
if let Ente... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/runtime/enter.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:2 | current thread while the thread is being used to drive \
asynchronous tasks."
);
}
/// Tries to enter a runtime context, returns `None` if already in a runtime
/// context.
pub(crate) fn try_enter(allow_blocking: bool) -> Option<Enter> {
ENTERED.with(|c| {
if c.get().is_entered() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/runtime/enter.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:3 | assert!(e.is_entered(), "asked to exit when not entered");
c.set(EnterContext::NotEntered);
e
});
let _reset = Reset(was);
// dropping _reset after f() will reset ENTERED
f()
}
cfg_rt_core! {
cfg_rt_util! {
/// Disallow blocking in the current runtime context until the guar... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/runtime/enter.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | c.set(EnterContext::Entered {
allow_blocking: true,
});
}
})
}
}
}
}
}
cfg_rt_threaded! {
cfg_blocking! {
/// Returns true if in a runtime context.
pub(cra... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | }
park.park()?;
}
}
}
cfg_blocking_impl! {
use crate::park::ParkError;
use std::time::Duration;
impl Enter {
/// Blocks the thread on the specified future for **at most** `timeout`
///
/// If the future completes before `timeout`, the result is returned. If... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/runtime/enter.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:6 | return Err(());
}
park.park_timeout(when - now)?;
}
}
}
}
impl fmt::Debug for Enter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Enter").finish()
}
}
impl Drop for Enter {
fn drop(&mut self) {
ENTERED.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/runtime/enter.rs | 201 | 223 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | c.set(EnterContext::Entered {
allow_blocking: true,
});
}
})
}
}
}
}
}
cfg_rt_threaded! {
cfg_blocking! {
/// Returns true if in a runtime context.
pub(cra... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 6b6e76080afc92450238df69c4edc12ee5f7518d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6b6e76080afc92450238df69c4edc12ee5f7518d/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | return Ok(v);
}
park.park()?;
}
}
}
}
cfg_blocking_impl! {
use crate::park::ParkError;
use std::time::Duration;
impl Enter {
/// Blocks the thread on the specified future for **at most** `timeout`
///
/// If the future comple... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 6b6e76080afc92450238df69c4edc12ee5f7518d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6b6e76080afc92450238df69c4edc12ee5f7518d/tokio/src/runtime/enter.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:6 | if now >= when {
return Err(());
}
park.park_timeout(when - now)?;
}
}
}
}
impl fmt::Debug for Enter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Enter").finish()
}
}
impl Drop for Enter {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 6b6e76080afc92450238df69c4edc12ee5f7518d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6b6e76080afc92450238df69c4edc12ee5f7518d/tokio/src/runtime/enter.rs | 201 | 225 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | c.set(EnterContext::Entered {
allow_blocking: true,
});
}
})
}
}
}
}
}
cfg_rt_threaded! {
cfg_blocking! {
/// Returns true if in a runtime context.
pub(cra... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d8139fef7a555f99adaa37e139787d26e24daba3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8139fef7a555f99adaa37e139787d26e24daba3/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | loop {
if let Ready(v) = crate::coop::budget(|| f.as_mut().poll(&mut cx)) {
return Ok(v);
}
park.park()?;
}
}
}
}
cfg_blocking_impl! {
use crate::park::ParkError;
use std::time::Duration;
impl Enter {
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d8139fef7a555f99adaa37e139787d26e24daba3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8139fef7a555f99adaa37e139787d26e24daba3/tokio/src/runtime/enter.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:6 | loop {
if let Ready(v) = crate::coop::budget(|| f.as_mut().poll(&mut cx)) {
return Ok(v);
}
let now = Instant::now();
if now >= when {
return Err(());
}
park.park_timeout(when - now... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | d8139fef7a555f99adaa37e139787d26e24daba3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8139fef7a555f99adaa37e139787d26e24daba3/tokio/src/runtime/enter.rs | 201 | 231 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:4 | c.set(EnterContext::Entered {
allow_blocking: true,
});
}
})
}
}
}
}
}
cfg_rt_threaded! {
cfg_blocking! {
/// Returns true if in a runtime context.
pub(cra... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 282b00cbe888a96669877ce70662fba87e8c0e3c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/enter.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:5 | // `block_on` takes ownership of `f`. Once it is pinned here, the original `f` binding can
// no longer be accessed, making the pinning safe.
let mut f = unsafe { Pin::new_unchecked(&mut f) };
loop {
if let Ready(v) = crate::coop::budget(|| f.as_mut().poll(&mut cx)) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 282b00cbe888a96669877ce70662fba87e8c0e3c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/enter.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:6 | let now = Instant::now();
if now >= when {
return Err(());
}
park.park_timeout(when - now)?;
}
}
}
}
impl fmt::Debug for Enter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Enter").f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 282b00cbe888a96669877ce70662fba87e8c0e3c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/enter.rs | 201 | 227 |
tokio-rs/tokio:tokio/src/runtime/enter.rs:1 | use std::cell::{Cell, RefCell};
use std::fmt;
use std::marker::PhantomData;
thread_local!(static ENTERED: Cell<bool> = Cell::new(false));
/// Represents an executor context.
pub(crate) struct Enter {
_p: PhantomData<RefCell<()>>,
}
/// Marks the current thread as being within the dynamic extent of an
/// executo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/enter.rs | MIT | 67c4cc03919a58076c139f0930f28c3c41dad1e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/enter.rs | 1 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.