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/io/registration.rs:5 | &self,
cx: &mut Context<'_>,
direction: Direction,
mut f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
loop {
let ev = ready!(self.poll_ready(cx, direction))?;
match f() {
Ok(ret) => {
return Poll::Ready(Ok(ret... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/registration.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:6 | pub(crate) async fn readiness(&self, interest: Interest) -> io::Result<ReadyEvent> {
let ev = self.shared.readiness(interest).await;
if ev.is_shutdown {
return Err(gone());
}
Ok(ev)
}
pub(crate) async fn async_io<R>(
&self,
interest: Interest,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/registration.rs | 201 | 252 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:7 | //
// See tokio-rs/tokio#3481 for more details.
self.shared.clear_wakers();
}
}
fn gone() -> io::Error {
io::Error::new(
io::ErrorKind::Other,
crate::util::error::RUNTIME_SHUTTING_DOWN_ERROR,
)
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/registration.rs | 241 | 252 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:5 | &self,
cx: &mut Context<'_>,
direction: Direction,
mut f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
loop {
let ev = ready!(self.poll_ready(cx, direction))?;
match f() {
Ok(ret) => {
return Poll::Ready(Ok(ret... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 7a99f87df203d589d9a8ad042a64b105a954f9fb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/runtime/io/registration.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:6 | fn handle(&self) -> &Handle {
self.handle.driver().io()
}
}
impl Drop for Registration {
fn drop(&mut self) {
// It is possible for a cycle to be created between wakers stored in
// `ScheduledIo` instances and `Arc<driver::Inner>`. To break this
// cycle, wakers are cleared. Thi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 7a99f87df203d589d9a8ad042a64b105a954f9fb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/runtime/io/registration.rs | 201 | 252 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:7 | let event = self.readiness(interest).await?;
match f() {
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
self.clear_readiness(event);
}
x => return x,
}
}
}
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 7a99f87df203d589d9a8ad042a64b105a954f9fb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/runtime/io/registration.rs | 241 | 252 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:7 | match f() {
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
self.clear_readiness(event);
}
x => return x,
}
}
}
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/registration.rs | 241 | 251 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:4 | &self,
cx: &mut Context<'_>,
f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
self.poll_io(cx, Direction::Read, f)
}
// Uses the poll path, requiring the caller to ensure mutual exclusion for
// correctness. Only the last task to call this function is notified.
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | a051ed726f3b99b077e8c9ef8ef1df2ab2943213 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a051ed726f3b99b077e8c9ef8ef1df2ab2943213/tokio/src/runtime/io/registration.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:5 | cx: &mut Context<'_>,
direction: Direction,
mut f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
loop {
let ev = ready!(self.poll_ready(cx, direction))?;
match f() {
Ok(ret) => {
return Poll::Ready(Ok(ret));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | a051ed726f3b99b077e8c9ef8ef1df2ab2943213 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a051ed726f3b99b077e8c9ef8ef1df2ab2943213/tokio/src/runtime/io/registration.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:6 | fn handle(&self) -> &Handle {
self.handle.driver().io()
}
}
impl Drop for Registration {
fn drop(&mut self) {
// It is possible for a cycle to be created between wakers stored in
// `ScheduledIo` instances and `Arc<driver::Inner>`. To break this
// cycle, wakers are cleared. Thi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | a051ed726f3b99b077e8c9ef8ef1df2ab2943213 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a051ed726f3b99b077e8c9ef8ef1df2ab2943213/tokio/src/runtime/io/registration.rs | 201 | 257 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:7 | }).await
}
pub(crate) async fn async_io<R>(&self, interest: Interest, mut f: impl FnMut() -> io::Result<R>) -> io::Result<R> {
loop {
let event = self.readiness(interest).await?;
match f() {
Err(ref e) if e.kind() == io::ErrorKind::WouldB... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | a051ed726f3b99b077e8c9ef8ef1df2ab2943213 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a051ed726f3b99b077e8c9ef8ef1df2ab2943213/tokio/src/runtime/io/registration.rs | 241 | 257 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:4 | &self,
cx: &mut Context<'_>,
f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
self.poll_io(cx, Direction::Read, f)
}
// Uses the poll path, requiring the caller to ensure mutual exclusion for
// correctness. Only the last task to call this function is notified.
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 7483509746e1d82d7fc3642fd8431116c96aa387 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7483509746e1d82d7fc3642fd8431116c96aa387/tokio/src/runtime/io/registration.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:2 | ///
/// [`new_with_interest_and_handle`]: method@Self::new_with_interest_and_handle
/// [`poll_read_ready`]: method@Self::poll_read_ready`
/// [`poll_write_ready`]: method@Self::poll_write_ready`
#[derive(Debug)]
pub(crate) struct Registration {
/// Handle to the associated runtime.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 32d68fe579f818d349103fa0e9fccf3d80a9f717 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32d68fe579f818d349103fa0e9fccf3d80a9f717/tokio/src/runtime/io/registration.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:5 | cx: &mut Context<'_>,
direction: Direction,
mut f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
loop {
let ev = ready!(self.poll_ready(cx, direction))?;
match f() {
Ok(ret) => {
return Poll::Ready(Ok(ret));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 32d68fe579f818d349103fa0e9fccf3d80a9f717 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32d68fe579f818d349103fa0e9fccf3d80a9f717/tokio/src/runtime/io/registration.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:6 | fn handle(&self) -> &Handle {
self.handle.io()
}
}
impl Drop for Registration {
fn drop(&mut self) {
// It is possible for a cycle to be created between wakers stored in
// `ScheduledIo` instances and `Arc<driver::Inner>`. To break this
// cycle, wakers are cleared. This is an i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 32d68fe579f818d349103fa0e9fccf3d80a9f717 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32d68fe579f818d349103fa0e9fccf3d80a9f717/tokio/src/runtime/io/registration.rs | 201 | 257 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:2 | ///
/// [`new_with_interest_and_handle`]: method@Self::new_with_interest_and_handle
/// [`poll_read_ready`]: method@Self::poll_read_ready`
/// [`poll_write_ready`]: method@Self::poll_write_ready`
#[derive(Debug)]
pub(crate) struct Registration {
/// Handle to the associated runtime.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | cb67f28fe3c99956959669277fde889bc2dc252e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb67f28fe3c99956959669277fde889bc2dc252e/tokio/src/runtime/io/registration.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:3 | /// Deregisters the I/O resource from the reactor it is associated with.
///
/// This function must be called before the I/O resource associated with the
/// registration is dropped.
///
/// Note that deregistering does not guarantee that the I/O resource can be
/// registered with a different r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | cb67f28fe3c99956959669277fde889bc2dc252e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb67f28fe3c99956959669277fde889bc2dc252e/tokio/src/runtime/io/registration.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:4 | &self,
cx: &mut Context<'_>,
f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
self.poll_io(cx, Direction::Read, f)
}
// Uses the poll path, requiring the caller to ensure mutual exclusion for
// correctness. Only the last task to call this function is notified.
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | cb67f28fe3c99956959669277fde889bc2dc252e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb67f28fe3c99956959669277fde889bc2dc252e/tokio/src/runtime/io/registration.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:6 | fn handle(&self) -> &Handle {
self.handle.io()
}
}
impl Drop for Registration {
fn drop(&mut self) {
// It is possible for a cycle to be created between wakers stored in
// `ScheduledIo` instances and `Arc<driver::Inner>`. To break this
// cycle, wakers are cleared. This is an i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | cb67f28fe3c99956959669277fde889bc2dc252e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb67f28fe3c99956959669277fde889bc2dc252e/tokio/src/runtime/io/registration.rs | 201 | 257 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:1 | #![cfg_attr(not(feature = "net"), allow(dead_code))]
use crate::io::interest::Interest;
use crate::runtime::io::{Direction, Handle, ReadyEvent, ScheduledIo};
use crate::util::slab;
use mio::event::Source;
use std::io;
use std::task::{Context, Poll};
cfg_io_driver! {
/// Associates an I/O resource with the reacto... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 0b1f640308d9ac4b9446e5523982eef0527b5bdf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b1f640308d9ac4b9446e5523982eef0527b5bdf/tokio/src/runtime/io/registration.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:2 | /// [`new_with_interest_and_handle`]: method@Self::new_with_interest_and_handle
/// [`poll_read_ready`]: method@Self::poll_read_ready`
/// [`poll_write_ready`]: method@Self::poll_write_ready`
#[derive(Debug)]
pub(crate) struct Registration {
/// Handle to the associated driver.
handle: H... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 0b1f640308d9ac4b9446e5523982eef0527b5bdf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b1f640308d9ac4b9446e5523982eef0527b5bdf/tokio/src/runtime/io/registration.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:3 | /// This function must be called before the I/O resource associated with the
/// registration is dropped.
///
/// Note that deregistering does not guarantee that the I/O resource can be
/// registered with a different reactor. Some I/O resource types can only be
/// associated with a single reactor ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 0b1f640308d9ac4b9446e5523982eef0527b5bdf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b1f640308d9ac4b9446e5523982eef0527b5bdf/tokio/src/runtime/io/registration.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:4 | f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
self.poll_io(cx, Direction::Read, f)
}
// Uses the poll path, requiring the caller to ensure mutual exclusion for
// correctness. Only the last task to call this function is notified.
pub(crate) fn poll_write_io<R>(
&self,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 0b1f640308d9ac4b9446e5523982eef0527b5bdf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b1f640308d9ac4b9446e5523982eef0527b5bdf/tokio/src/runtime/io/registration.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:5 | mut f: impl FnMut() -> io::Result<R>,
) -> Poll<io::Result<R>> {
loop {
let ev = ready!(self.poll_ready(cx, direction))?;
match f() {
Ok(ret) => {
return Poll::Ready(Ok(ret));
}
Err(ref e) if e.kind() == io::ErrorKi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 0b1f640308d9ac4b9446e5523982eef0527b5bdf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b1f640308d9ac4b9446e5523982eef0527b5bdf/tokio/src/runtime/io/registration.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/registration.rs:6 | fn drop(&mut self) {
// It is possible for a cycle to be created between wakers stored in
// `ScheduledIo` instances and `Arc<driver::Inner>`. To break this
// cycle, wakers are cleared. This is an imperfect solution as it is
// possible to store a `Registration` in a waker. In this case... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration.rs | MIT | 0b1f640308d9ac4b9446e5523982eef0527b5bdf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b1f640308d9ac4b9446e5523982eef0527b5bdf/tokio/src/runtime/io/registration.rs | 201 | 251 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::runtime::io::ScheduledIo;
use crate::util::linked_list::{self, LinkedList};
use std::io;
use std::ptr::NonNull;
use std::sync::atomic::Ordering::{Acquire, Release};
use std::sync::Arc;
// Kind of arbitrary, but buffering 16 `ScheduledIo`s doesn't seem like much
c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/registration_set.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:2 | pending_release: Vec::with_capacity(NOTIFY_AFTER),
};
(set, synced)
}
pub(super) fn is_shutdown(&self, synced: &Synced) -> bool {
synced.is_shutdown
}
/// Returns `true` if there are registrations that need to be released
pub(super) fn needs_release(&self) -> bool {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/registration_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:3 | }
pub(super) fn shutdown(&self, synced: &mut Synced) -> Vec<Arc<ScheduledIo>> {
if synced.is_shutdown {
return vec![];
}
synced.is_shutdown = true;
synced.pending_release.clear();
// Building a vec of all outstanding I/O handles could be expensive, but
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/registration_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:4 | super::EXPOSE_IO.unexpose_provenance(io.as_ptr());
// SAFETY: the caller guarantees that `io` is part of this list.
let _ = unsafe { synced.registrations.remove(io) };
}
}
// Safety: `Arc` pins the inner data
unsafe impl linked_list::Link for Arc<ScheduledIo> {
type Handle = Arc<ScheduledIo>;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/registration_set.rs | 121 | 149 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:3 | }
pub(super) fn shutdown(&self, synced: &mut Synced) -> Vec<Arc<ScheduledIo>> {
if synced.is_shutdown {
return vec![];
}
synced.is_shutdown = true;
synced.pending_release.clear();
// Building a vec of all outstanding I/O handles could be expensive, but
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | 21a13f9eea1723f6ca1b5e106776d0b1d5df80ea | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21a13f9eea1723f6ca1b5e106776d0b1d5df80ea/tokio/src/runtime/io/registration_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:4 | super::EXPOSE_IO.unexpose_provenance(io.as_ptr());
let _ = synced.registrations.remove(io);
}
}
// Safety: `Arc` pins the inner data
unsafe impl linked_list::Link for Arc<ScheduledIo> {
type Handle = Arc<ScheduledIo>;
type Target = ScheduledIo;
fn as_raw(handle: &Self::Handle) -> NonNull<Sched... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | 21a13f9eea1723f6ca1b5e106776d0b1d5df80ea | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21a13f9eea1723f6ca1b5e106776d0b1d5df80ea/tokio/src/runtime/io/registration_set.rs | 121 | 146 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::runtime::io::ScheduledIo;
use crate::util::linked_list::{self, LinkedList};
use std::io;
use std::ptr::NonNull;
use std::sync::atomic::Ordering::{Acquire, Release};
use std::sync::Arc;
pub(super) struct RegistrationSet {
num_pending_release: AtomicUsize,
}
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | 2f899144ed0fb3701bf0996578803ae9df80ebda | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2f899144ed0fb3701bf0996578803ae9df80ebda/tokio/src/runtime/io/registration_set.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:2 | (set, synced)
}
pub(super) fn is_shutdown(&self, synced: &Synced) -> bool {
synced.is_shutdown
}
/// Returns `true` if there are registrations that need to be released
pub(super) fn needs_release(&self) -> bool {
self.num_pending_release.load(Acquire) != 0
}
pub(super) fn ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | 2f899144ed0fb3701bf0996578803ae9df80ebda | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2f899144ed0fb3701bf0996578803ae9df80ebda/tokio/src/runtime/io/registration_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:3 | }
pub(super) fn shutdown(&self, synced: &mut Synced) -> Vec<Arc<ScheduledIo>> {
if synced.is_shutdown {
return vec![];
}
synced.is_shutdown = true;
synced.pending_release.clear();
// Building a vec of all outstanding I/O handles could be expensive, but
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/registration_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:4 | }
// Safety: `Arc` pins the inner data
unsafe impl linked_list::Link for Arc<ScheduledIo> {
type Handle = Arc<ScheduledIo>;
type Target = ScheduledIo;
fn as_raw(handle: &Self::Handle) -> NonNull<ScheduledIo> {
// safety: Arc::as_ptr never returns null
unsafe { NonNull::new_unchecked(Arc::a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/registration_set.rs | 121 | 143 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:3 | }
pub(super) fn shutdown(&self, synced: &mut Synced) -> Vec<Arc<ScheduledIo>> {
if synced.is_shutdown {
return vec![];
}
synced.is_shutdown = true;
synced.pending_release.clear();
// Building a vec of all outstanding I/O handles could be expensive, but
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | b32826bc937a34e4d871c89bb2c3711ed3e20cdc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b32826bc937a34e4d871c89bb2c3711ed3e20cdc/tokio/src/runtime/io/registration_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:4 | // Safety: `Arc` pins the inner data
unsafe impl linked_list::Link for Arc<ScheduledIo> {
type Handle = Arc<ScheduledIo>;
type Target = ScheduledIo;
fn as_raw(handle: &Self::Handle) -> NonNull<ScheduledIo> {
// safety: Arc::as_ptr never returns null
unsafe { NonNull::new_unchecked(Arc::as_p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | b32826bc937a34e4d871c89bb2c3711ed3e20cdc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b32826bc937a34e4d871c89bb2c3711ed3e20cdc/tokio/src/runtime/io/registration_set.rs | 121 | 142 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:3 | }
pub(super) fn shutdown(&self, synced: &mut Synced) -> Vec<Arc<ScheduledIo>> {
if synced.is_shutdown {
return vec![];
}
synced.is_shutdown = true;
synced.pending_release.clear();
// Building a vec of all outstanding I/O handles could be expensive, but
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/registration_set.rs | 81 | 134 |
tokio-rs/tokio:tokio/src/runtime/io/registration_set.rs:4 | unsafe { NonNull::new_unchecked(Arc::as_ptr(handle) as *mut _) }
}
unsafe fn from_raw(ptr: NonNull<Self::Target>) -> Arc<ScheduledIo> {
// safety: the linked list currently owns a ref count
unsafe { Arc::from_raw(ptr.as_ptr() as *const _) }
}
unsafe fn pointers(
target: NonNull... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/registration_set.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/registration_set.rs | 121 | 134 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:1 | use crate::io::interest::Interest;
use crate::io::ready::Ready;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::runtime::io::{Direction, ReadyEvent, Tick};
use crate::util::bit;
use crate::util::linked_list::{self, LinkedList};
use crate::util::WakeList;
use std::cell::UnsafeCell;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:2 | target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64",
),
repr(align(128))
)]
// arm, mips, mips64, sparc, and hexagon have 32-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_arm.go#L7
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:3 | // - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_wasm.go#L7
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L19
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:4 | writer: Option<Waker>,
}
#[derive(Debug)]
struct Waiter {
pointers: linked_list::Pointers<Waiter>,
/// The waker for this task.
waker: Option<Waker>,
/// The interest this waiter is waiting on.
interest: Interest,
is_ready: bool,
/// Should never be `Unpin`.
_p: PhantomPinned,
}
ge... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 15 bits | 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(15... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | /// Sets the readiness on this `ScheduledIo` by invoking the given closure on
/// the current value, returning the previous readiness value.
///
/// # Arguments
/// - `tick`: whether setting the tick or trying to clear readiness for a
/// specific tick.
/// - `f`: a closure returning a new rea... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | let mut waiters = self.waiters.lock();
// check for AsyncRead slot
if ready.is_readable() {
if let Some(waker) = waiters.reader.take() {
wakers.push(waker);
}
}
// check for AsyncWrite slot
if ready.is_writable() {
if let Some... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | waiters = self.waiters.lock();
}
// Release the lock before notifying
drop(waiters);
wakers.wake_all();
}
pub(super) fn ready_event(&self, interest: Interest) -> ReadyEvent {
let curr = self.readiness.load(Acquire);
ReadyEvent {
tick: TICK.unpack(c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | };
// Avoid cloning the waker if one is already stored that matches the
// current task.
match waker {
Some(waker) => waker.clone_from(cx.waker()),
None => *waker = Some(cx.waker().clone()),
}
// Try again, in case the readine... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | // states. Closed states are excluded because they are final states.
let mask_no_closed = event.ready - Ready::READ_CLOSED - Ready::WRITE_CLOSED;
self.set_readiness(Tick::Clear(event.tick), |curr| curr - mask_no_closed);
}
pub(crate) fn clear_wakers(&self) {
let mut waiters = self.waite... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | _p: PhantomPinned,
}),
}
}
}
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | (me.scheduled_io, &mut me.state, &me.waiter)
};
loop {
match *state {
State::Init => {
// Optimistically check existing readiness
let curr = scheduled_io.readiness.load(SeqCst);
let is_shutdown = SHUTDOWN.unpack(cur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | let tick = TICK.unpack(curr) as u8;
*state = State::Done;
return Poll::Ready(ReadyEvent {
tick,
ready,
is_shutdown,
});
}
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | if w.is_ready {
// Our waker has been notified.
*state = State::Done;
} else {
// Update the waker, if necessary.
w.waker.as_mut().unwrap().clone_from(cx.waker());
return Poll::Pen... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:15 | });
}
}
}
}
}
impl Drop for Readiness<'_> {
fn drop(&mut self) {
let mut waiters = self.scheduled_io.waiters.lock();
// Safety: `waiter` is only ever stored in `waiters`
unsafe {
waiters
.list
.remove(NonNu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/io/scheduled_io.rs | 561 | 582 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | // states. Closed states are excluded because they are final states.
let mask_no_closed = event.ready - Ready::READ_CLOSED - Ready::WRITE_CLOSED;
self.set_readiness(Tick::Clear(event.tick), |curr| curr - mask_no_closed);
}
pub(crate) fn clear_wakers(&self) {
let mut waiters = self.waite... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | _p: PhantomPinned,
}),
}
}
}
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 15 bits | 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(15... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 02cbe4591b71bcfb7e775a9a09685885ce4f860e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/02cbe4591b71bcfb7e775a9a09685885ce4f860e/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | /// Sets the readiness on this `ScheduledIo` by invoking the given closure on
/// the current value, returning the previous readiness value.
///
/// # Arguments
/// - `tick`: whether setting the tick or trying to clear readiness for a
/// specific tick.
/// - `f`: a closure returning a new re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 02cbe4591b71bcfb7e775a9a09685885ce4f860e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/02cbe4591b71bcfb7e775a9a09685885ce4f860e/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:3 | // - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_wasm.go#L7
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L19
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c07257f99f92c5d6773fc0827bcfd77e43f0fd46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c07257f99f92c5d6773fc0827bcfd77e43f0fd46/tokio/src/runtime/io/scheduled_io.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:4 | writer: Option<Waker>,
}
#[derive(Debug)]
struct Waiter {
pointers: linked_list::Pointers<Waiter>,
/// The waker for this task.
waker: Option<Waker>,
/// The interest this waiter is waiting on.
interest: Interest,
is_ready: bool,
/// Should never be `!Unpin`.
_p: PhantomPinned,
}
g... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c07257f99f92c5d6773fc0827bcfd77e43f0fd46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c07257f99f92c5d6773fc0827bcfd77e43f0fd46/tokio/src/runtime/io/scheduled_io.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 15 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(15... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c07257f99f92c5d6773fc0827bcfd77e43f0fd46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c07257f99f92c5d6773fc0827bcfd77e43f0fd46/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | _p: PhantomPinned,
}),
}
}
}
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c07257f99f92c5d6773fc0827bcfd77e43f0fd46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c07257f99f92c5d6773fc0827bcfd77e43f0fd46/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | let curr = scheduled_io.readiness.load(SeqCst);
let is_shutdown = SHUTDOWN.unpack(curr) != 0;
// Safety: `waiter.interest` never changes
let interest = unsafe { (*waiter.get()).interest };
let ready = Ready::from_usize(READINESS.unpack(cur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c07257f99f92c5d6773fc0827bcfd77e43f0fd46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c07257f99f92c5d6773fc0827bcfd77e43f0fd46/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | }
// Not ready even after locked, insert into list...
// Safety: called while locked
unsafe {
(*waiter.get()).waker = Some(cx.waker().clone());
}
// Insert the waiter into the linked list
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c07257f99f92c5d6773fc0827bcfd77e43f0fd46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c07257f99f92c5d6773fc0827bcfd77e43f0fd46/tokio/src/runtime/io/scheduled_io.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | // is helpful to visualize the scope of the critical
// section.
drop(waiters);
}
State::Done => {
// Safety: State::Done means it is no longer shared
let w = unsafe { &mut *waiter.get() };
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | c07257f99f92c5d6773fc0827bcfd77e43f0fd46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c07257f99f92c5d6773fc0827bcfd77e43f0fd46/tokio/src/runtime/io/scheduled_io.rs | 521 | 566 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 15 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(15... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | /// Sets the readiness on this `ScheduledIo` by invoking the given closure on
/// the current value, returning the previous readiness value.
///
/// # Arguments
/// - `tick`: whether setting the tick or trying to clear readiness for a
/// specific tick.
/// - `f`: a closure returning a new re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | Ok(_) => return,
// we lost the race, retry!
Err(actual) => current = actual,
}
}
}
/// Notifies all pending waiters that have registered interest in `ready`.
///
/// There may be many waiters to notify. Waking the pending task **must** be
/// don... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | match iter.next() {
Some(waiter) => {
let waiter = unsafe { &mut *waiter.as_ptr() };
if let Some(waker) = waiter.waker.take() {
waiter.is_ready = true;
wakers.push(waker);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | ///
/// These are to support `AsyncRead` and `AsyncWrite` polling methods,
/// which cannot use the `async fn` version. This uses reserved reader
/// and writer slots.
pub(super) fn poll_readiness(
&self,
cx: &mut Context<'_>,
direction: Direction,
) -> Poll<ReadyEvent> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | if is_shutdown {
Poll::Ready(ReadyEvent {
tick: TICK.unpack(curr) as u8,
ready: direction.mask(),
is_shutdown,
})
} else if ready.is_empty() {
Poll::Pending
} else {
Poll::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | self.wake(Ready::ALL);
}
}
unsafe impl Send for ScheduledIo {}
unsafe impl Sync for ScheduledIo {}
impl ScheduledIo {
/// An async version of `poll_readiness` which uses a linked list of wakers.
pub(crate) async fn readiness(&self, interest: Interest) -> ReadyEvent {
self.readiness_fut(interest).a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
}
unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> {
Waiter::addr_of_pointers(target)
}
}
// ===== impl Readiness =====
impl Future for Readiness<'_> {
type Output = ReadyEvent;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | ready,
is_shutdown,
});
}
// Wasn't ready, take the lock (and check again while locked).
let mut waiters = scheduled_io.waiters.lock();
let curr = scheduled_io.readiness.load(SeqCst);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | .list
.push_front(unsafe { NonNull::new_unchecked(waiter.get()) });
*state = State::Waiting;
}
State::Waiting => {
// Currently in the "Waiting" state, implying the caller has
// a waiter stored in the wa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:15 | // The returned tick might be newer than the event
// which notified our waker. This is ok because the future
// still didn't return `Poll::Ready`.
let tick = TICK.unpack(curr) as u8;
// The readiness state could have been cleared in the m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 21cf5a546916b612931d764b3ce2bb7d4412021e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21cf5a546916b612931d764b3ce2bb7d4412021e/tokio/src/runtime/io/scheduled_io.rs | 561 | 597 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 15 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(15... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | {
Ok(_) => return,
// we lost the race, retry!
Err(actual) => current = actual,
}
}
}
/// Notifies all pending waiters that have registered interest in `ready`.
///
/// There may be many waiters to notify. Waking the pending task **mus... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | while wakers.can_push() {
match iter.next() {
Some(waiter) => {
let waiter = unsafe { &mut *waiter.as_ptr() };
if let Some(waker) = waiter.waker.take() {
waiter.is_ready = true;
w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | /// Polls for readiness events in a given direction.
///
/// These are to support `AsyncRead` and `AsyncWrite` polling methods,
/// which cannot use the `async fn` version. This uses reserved reader
/// and writer slots.
pub(super) fn poll_readiness(
&self,
cx: &mut Context<'_>,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | let is_shutdown = SHUTDOWN.unpack(curr) != 0;
if is_shutdown {
Poll::Ready(ReadyEvent {
tick: TICK.unpack(curr) as u8,
ready: direction.mask(),
is_shutdown,
})
} else if ready.is_empty() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | fn drop(&mut self) {
self.wake(Ready::ALL);
}
}
unsafe impl Send for ScheduledIo {}
unsafe impl Sync for ScheduledIo {}
impl ScheduledIo {
/// An async version of `poll_readiness` which uses a linked list of wakers.
pub(crate) async fn readiness(&self, interest: Interest) -> ReadyEvent {
s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
}
unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> {
Waiter::addr_of_pointers(target)
}
}
// ===== impl Readiness =====
impl Future for Readiness<'_> {
type Output = ReadyEvent;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | tick,
ready,
is_shutdown,
});
}
// Wasn't ready, take the lock (and check again while locked).
let mut waiters = scheduled_io.waiters.lock();
let curr = sched... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | waiters
.list
.push_front(unsafe { NonNull::new_unchecked(waiter.get()) });
*state = State::Waiting;
}
State::Waiting => {
// Currently in the "Waiting" state, implying the caller has
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:15 | let is_shutdown = SHUTDOWN.unpack(curr) != 0;
// The returned tick might be newer than the event
// which notified our waker. This is ok because the future
// still didn't return `Poll::Ready`.
let tick = TICK.unpack(curr) as u8;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | be9328da75c34b14dbbf017c344fee6219985559 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/runtime/io/scheduled_io.rs | 561 | 598 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | /// Polls for readiness events in a given direction.
///
/// These are to support `AsyncRead` and `AsyncWrite` polling methods,
/// which cannot use the `async fn` version. This uses reserved reader
/// and writer slots.
pub(super) fn poll_readiness(
&self,
cx: &mut Context<'_>,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:3 | // - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_wasm.go#L7
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L19
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 19d96c067410e30da29978be3513824645902a84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/19d96c067410e30da29978be3513824645902a84/tokio/src/runtime/io/scheduled_io.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 15 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(15... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 19d96c067410e30da29978be3513824645902a84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/19d96c067410e30da29978be3513824645902a84/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:4 | writer: Option<Waker>,
}
#[derive(Debug)]
struct Waiter {
pointers: linked_list::Pointers<Waiter>,
/// The waker for this task.
waker: Option<Waker>,
/// The interest this waiter is waiting on.
interest: Interest,
is_ready: bool,
/// Should never be `!Unpin`.
_p: PhantomPinned,
}
g... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 30b2eb17c8172620a9e6d90d8be46e294594a5cc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/30b2eb17c8172620a9e6d90d8be46e294594a5cc/tokio/src/runtime/io/scheduled_io.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 8 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(8)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 30b2eb17c8172620a9e6d90d8be46e294594a5cc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/30b2eb17c8172620a9e6d90d8be46e294594a5cc/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | /// Sets the readiness on this `ScheduledIo` by invoking the given closure on
/// the current value, returning the previous readiness value.
///
/// # Arguments
/// - `tick`: whether setting the tick or trying to clear readiness for a
/// specific tick.
/// - `f`: a closure returning a new re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | }
}
}
/// Notifies all pending waiters that have registered interest in `ready`.
///
/// There may be many waiters to notify. Waking the pending task **must** be
/// done from outside of the lock otherwise there is a potential for a
/// deadlock.
///
/// A stack array of wakers ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | if let Some(waker) = waiter.waker.take() {
waiter.is_ready = true;
wakers.push(waker);
}
}
None => {
break 'outer;
}
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | /// and writer slots.
pub(super) fn poll_readiness(
&self,
cx: &mut Context<'_>,
direction: Direction,
) -> Poll<ReadyEvent> {
let curr = self.readiness.load(Acquire);
let ready = direction.mask() & Ready::from_usize(READINESS.unpack(curr));
let is_shutdown = SHU... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | ready: direction.mask(),
is_shutdown,
})
} else if ready.is_empty() {
Poll::Pending
} else {
Poll::Ready(ReadyEvent {
tick: TICK.unpack(curr) as u8,
ready,
is_shutdown,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | unsafe impl Send for ScheduledIo {}
unsafe impl Sync for ScheduledIo {}
impl ScheduledIo {
/// An async version of `poll_readiness` which uses a linked list of wakers.
pub(crate) async fn readiness(&self, interest: Interest) -> ReadyEvent {
self.readiness_fut(interest).await
}
// This is in a ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> {
Waiter::addr_of_pointers(target)
}
}
// ===== impl Readiness =====
impl Future for Readiness<'_> {
type Output = ReadyEvent;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | }
// Wasn't ready, take the lock (and check again while locked).
let mut waiters = scheduled_io.waiters.lock();
let curr = scheduled_io.readiness.load(SeqCst);
let mut ready = Ready::from_usize(READINESS.unpack(curr));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | }
State::Waiting => {
// Currently in the "Waiting" state, implying the caller has
// a waiter stored in the waiter list (guarded by
// `notify.waiters`). In order to access the waker fields,
// we must hold the lock.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 521 | 580 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.