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/timer/wheel/mod.rs:7 | fn level_for(elapsed: u64, when: u64) -> usize {
let masked = elapsed ^ when;
assert!(masked != 0, "elapsed={}; when={}", elapsed, when);
let leading_zeros = masked.leading_zeros() as usize;
let significant = 63 - leading_zeros;
significant / 6
}
impl Poll {
pub(crate) fn new(now: u64) -> Pol... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/timer/wheel/mod.rs | MIT | 7eb264a0d0ee68433b20ecafabed53a70a9d43a4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7eb264a0d0ee68433b20ecafabed53a70a9d43a4/tokio/src/timer/wheel/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/timer/wheel/mod.rs:8 | level_for(0, a as u64),
"level_for({}) -- binary = {:b}",
a,
a
);
if pos > level {
let a = a - 1;
assert_eq!(
level,
level_for(0, a as u64)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/timer/wheel/mod.rs | MIT | 7eb264a0d0ee68433b20ecafabed53a70a9d43a4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7eb264a0d0ee68433b20ecafabed53a70a9d43a4/tokio/src/timer/wheel/mod.rs | 281 | 311 |
tokio-rs/tokio:tokio/src/util/as_ref.rs:1 | use super::typeid;
#[derive(Debug)]
pub(crate) enum OwnedBuf {
Vec(Vec<u8>),
#[cfg(feature = "io-util")]
Bytes(bytes::Bytes),
}
impl AsRef<[u8]> for OwnedBuf {
fn as_ref(&self) -> &[u8] {
match self {
Self::Vec(vec) => vec,
#[cfg(feature = "io-util")]
Self::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/as_ref.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/as_ref.rs | 1 | 38 |
tokio-rs/tokio:tokio/src/util/atomic_cell.rs:1 | use crate::loom::sync::atomic::AtomicPtr;
use std::ptr;
use std::sync::atomic::Ordering::AcqRel;
pub(crate) struct AtomicCell<T> {
data: AtomicPtr<T>,
}
unsafe impl<T: Send> Send for AtomicCell<T> {}
unsafe impl<T: Send> Sync for AtomicCell<T> {}
impl<T> AtomicCell<T> {
pub(crate) fn new(data: Option<Box<T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/atomic_cell.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/atomic_cell.rs | 1 | 51 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy, PartialEq)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` least-significant bits.
pub(crate) const fn least_significant(width: u32) -> Pack {
let mask = mask_for(width);
Pack { mask, shift: 0 }
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:2 | unpack(src, self.mask, self.shift)
}
}
impl fmt::Debug for Pack {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
fmt,
"Pack {{ mask: {:b}, shift: {} }}",
self.mask, self.shift
)
}
}
/// Returns a `usize` with the right-most `n` bits... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/bit.rs | 41 | 64 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy, PartialEq)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` least-significant bits.
pub(crate) const fn least_significant(width: u32) -> Pack {
let mask = mask_for(width);
Pack { mask, shift: 0 }
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:2 | unpack(src, self.mask, self.shift)
}
}
impl fmt::Debug for Pack {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
fmt,
"Pack {{ mask: {:b}, shift: {} }}",
self.mask, self.shift
)
}
}
/// Returns the width of a pointer in bits.
pub(cr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/util/bit.rs | 41 | 69 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy, PartialEq)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` least-significant bits.
pub(crate) const fn least_significant(width: u32) -> Pack {
let mask = mask_for(width);
Pack { mask, shift: 0 }
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:2 | ///
/// If `value` is larger than the max value that can be represented by the
/// allotted width, the most significant bits are truncated.
pub(crate) fn pack_lossy(&self, value: usize, base: usize) -> usize {
self.pack(value & self.max_value(), base)
}
pub(crate) fn unpack(&self, src: usiz... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/bit.rs | 41 | 77 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy, PartialEq)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` least-significant bits.
pub(crate) const fn least_significant(width: u32) -> Pack {
let mask = mask_for(width);
Pack { mask, shift: 0 }
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | a0557840eb424e174bf81a0175c40f9e176a2cc2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:2 | ///
/// If `value` is larger than the max value that can be represented by the
/// allotted width, the most significant bits are truncated.
pub(crate) fn pack_lossy(&self, value: usize, base: usize) -> usize {
self.pack(value & self.max_value(), base)
}
pub(crate) fn unpack(&self, src: usiz... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | a0557840eb424e174bf81a0175c40f9e176a2cc2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/util/bit.rs | 41 | 77 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` least-significant bits.
pub(crate) const fn least_significant(width: u32) -> Pack {
let mask = mask_for(width);
Pack { mask, shift: 0 }
}
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 6866b24ca1a89fb6e7dbc63e20d8a66ee60a85b8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6866b24ca1a89fb6e7dbc63e20d8a66ee60a85b8/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` least-significant bits.
pub(crate) const fn least_significant(width: u32) -> Pack {
let mask = mask_for(width);
Pack { mask, shift: 0 }
}
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 8feebab7cdef2fbeb810d18509b1443b6b9f60b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8feebab7cdef2fbeb810d18509b1443b6b9f60b1/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:2 | pub(crate) fn pack(&self, value: usize, base: usize) -> usize {
assert!(value <= self.max_value());
(base & !self.mask) | (value << self.shift)
}
/// Packs the value with `base`, losing any bits of `value` that fit.
///
/// If `value` is larger than the max value that can be represented... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 8feebab7cdef2fbeb810d18509b1443b6b9f60b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8feebab7cdef2fbeb810d18509b1443b6b9f60b1/tokio/src/util/bit.rs | 41 | 83 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` most-significant bits.
pub(crate) const fn most_significant(width: u32) -> Pack {
let mask = mask_for(width).reverse_bits();
Pack {
mask,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | c1232a65207e3b2d42d82b9144658f6293287089 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1232a65207e3b2d42d82b9144658f6293287089/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:2 | /// Width, in bits, dedicated to storing the value.
pub(crate) const fn width(&self) -> u32 {
pointer_width() - (self.mask >> self.shift).leading_zeros()
}
/// Max representable value
pub(crate) const fn max_value(&self) -> usize {
(1 << self.width()) - 1
}
pub(crate) fn pack(&... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | c1232a65207e3b2d42d82b9144658f6293287089 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1232a65207e3b2d42d82b9144658f6293287089/tokio/src/util/bit.rs | 41 | 85 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` most-significant bits.
pub(crate) const fn most_significant(width: u32) -> Pack {
let mask = mask_for(width).reverse_bits();
Pack {
mask,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 8656b7b8eb6f3635ec40694eb71f14fb84211e05 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8656b7b8eb6f3635ec40694eb71f14fb84211e05/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:2 | pub(crate) const fn width(&self) -> u32 {
pointer_width() - (self.mask >> self.shift).leading_zeros()
}
/// Max representable value
pub(crate) const fn max_value(&self) -> usize {
(1 << self.width()) - 1
}
pub(crate) fn pack(&self, value: usize, base: usize) -> usize {
asse... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 8656b7b8eb6f3635ec40694eb71f14fb84211e05 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8656b7b8eb6f3635ec40694eb71f14fb84211e05/tokio/src/util/bit.rs | 41 | 84 |
tokio-rs/tokio:tokio/src/util/bit.rs:1 | use std::fmt;
#[derive(Clone, Copy)]
pub(crate) struct Pack {
mask: usize,
shift: u32,
}
impl Pack {
/// Value is packed in the `width` most-significant bits.
pub(crate) const fn most_significant(width: u32) -> Pack {
let mask = mask_for(width).reverse_bits();
Pack {
mask,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 69975fb9601bbb21659db283d888470733bae660 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69975fb9601bbb21659db283d888470733bae660/tokio/src/util/bit.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/bit.rs:2 | /// Mask used to unpack value
pub(crate) const fn mask(&self) -> usize {
self.mask
}
/// Width, in bits, dedicated to storing the value.
pub(crate) const fn width(&self) -> u32 {
pointer_width() - (self.mask >> self.shift).leading_zeros()
}
/// Max representable value
pub(c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/bit.rs | MIT | 69975fb9601bbb21659db283d888470733bae660 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69975fb9601bbb21659db283d888470733bae660/tokio/src/util/bit.rs | 41 | 86 |
tokio-rs/tokio:tokio/src/util/blocking_check.rs:1 | #[cfg(unix)]
use std::os::fd::AsFd;
#[cfg(unix)]
#[allow(unused_variables)]
#[track_caller]
pub(crate) fn check_socket_for_blocking<S: AsFd>(s: &S) -> crate::io::Result<()> {
#[cfg(not(tokio_allow_from_blocking_fd))]
{
let sock = socket2::SockRef::from(s);
debug_assert!(
sock.nonbl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/blocking_check.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/blocking_check.rs | 1 | 29 |
tokio-rs/tokio:tokio/src/util/cacheline.rs:1 | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
use std::ops::{Deref, DerefMut};
/// Pads and aligns a value to the length of a cache line.
#[derive(Clone, Copy, Default, Hash, PartialEq, Eq)]
// Starting from Intel's Sandy Bridge, spatial prefetcher is now pulling pairs of 64-byte cache
// line... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/cacheline.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/cacheline.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/cacheline.rs:2 | // s390x has 256-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_s390x.go#L7
#[cfg_attr(target_arch = "s390x", repr(align(256)))]
// x86, riscv and wasm have 64-byte cache line size.
//
// Sources:
// - https://github.com/golang/g... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/cacheline.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/cacheline.rs | 41 | 89 |
tokio-rs/tokio:tokio/src/util/cacheline.rs:1 | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
use std::ops::{Deref, DerefMut};
/// Pads and aligns a value to the length of a cache line.
#[derive(Clone, Copy, Default, Hash, PartialEq, Eq)]
// Starting from Intel's Sandy Bridge, spatial prefetcher is now pulling pairs of 64-byte cache
// line... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/cacheline.rs | MIT | 38d1bcd9df6af2de436c5f898829d071f8e46988 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/38d1bcd9df6af2de436c5f898829d071f8e46988/tokio/src/util/cacheline.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/cacheline.rs:2 | target_arch = "mips",
target_arch = "mips64",
target_arch = "riscv64",
),
repr(align(32))
)]
// s390x has 256-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_s390x.go#L7
#[cfg_attr(target_arch = "s390x", re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/cacheline.rs | MIT | 38d1bcd9df6af2de436c5f898829d071f8e46988 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/38d1bcd9df6af2de436c5f898829d071f8e46988/tokio/src/util/cacheline.rs | 41 | 95 |
tokio-rs/tokio:tokio/src/util/cacheline.rs:3 | }
impl<T> Deref for CachePadded<T> {
type Target = T;
fn deref(&self) -> &T {
&self.value
}
}
impl<T> DerefMut for CachePadded<T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.value
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/cacheline.rs | MIT | 38d1bcd9df6af2de436c5f898829d071f8e46988 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/38d1bcd9df6af2de436c5f898829d071f8e46988/tokio/src/util/cacheline.rs | 81 | 95 |
tokio-rs/tokio:tokio/src/util/enumerate.rs:1 | use futures::{try_ready, Async, Poll, Sink, StartSend, Stream};
/// A stream combinator which combines the yields the current item
/// plus its count starting from 0.
///
/// This structure is produced by the `Stream::enumerate` method.
#[derive(Debug)]
#[must_use = "Does nothing unless polled"]
pub struct Enumerate<T... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/enumerate.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/src/util/enumerate.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/enumerate.rs:2 | pub fn into_inner(self) -> T {
self.inner
}
}
impl<T> Stream for Enumerate<T>
where
T: Stream,
{
type Item = (usize, T::Item);
type Error = T::Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, T::Error> {
match try_ready!(self.inner.poll()) {
Some(item) => {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/enumerate.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/src/util/enumerate.rs | 41 | 84 |
tokio-rs/tokio:tokio/src/util/error.rs:1 | // Some combinations of features may not use these constants.
#![cfg_attr(not(feature = "full"), allow(dead_code))]
/// Error string explaining that the Tokio context hasn't been instantiated.
pub(crate) const CONTEXT_MISSING_ERROR: &str =
"there is no reactor running, must be called from the context of a Tokio 1.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/error.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/error.rs | 1 | 16 |
tokio-rs/tokio:tokio/src/util/error.rs:1 | /// Error string explaining that the Tokio context hasn't been instantiated.
pub(crate) const CONTEXT_MISSING_ERROR: &str =
"there is no reactor running, must be called from the context of a Tokio 1.x runtime";
// some combinations of features might not use this
#[allow(dead_code)]
/// Error string explaining that... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/error.rs | MIT | 1f8105588c06c41c90c3c77628d10cde4b3b2edb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f8105588c06c41c90c3c77628d10cde4b3b2edb/tokio/src/util/error.rs | 1 | 17 |
tokio-rs/tokio:tokio/src/util/error.rs:1 | /// Error string explaining that the Tokio context hasn't been instantiated.
pub(crate) const CONTEXT_MISSING_ERROR: &str =
"there is no reactor running, must be called from the context of a Tokio 1.x runtime";
// some combinations of features might not use this
#[allow(dead_code)]
/// Error string explaining that... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/error.rs | MIT | c39d9867bb989396bb02e74d87f2805969f43f03 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/util/error.rs | 1 | 9 |
tokio-rs/tokio:tokio/src/util/future.rs:2 | ///
/// # fn long_future() -> FutureResult<(), ()> {
/// # future::ok(())
/// # }
/// #
/// # fn main() {
/// let future = long_future()
/// .timeout(Duration::from_secs(1))
/// .map_err(|e| println!("error = {:?}", e));
///
/// tokio::run(future);
/// # }
/// `... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/future.rs | MIT | 70eca184f0f52dd2d634b750bba698da9418ee5f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/70eca184f0f52dd2d634b750bba698da9418ee5f/tokio/src/util/future.rs | 41 | 63 |
tokio-rs/tokio:tokio/src/util/future.rs:2 | /// ```
/// use tokio::prelude::*;
/// use std::time::Duration;
/// # use futures::future::{self, FutureResult};
///
/// # fn long_future() -> FutureResult<(), ()> {
/// # future::ok(())
/// # }
/// #
/// # fn main() {
/// let future = long_future()
/// .timeout(Duratio... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/future.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/src/util/future.rs | 41 | 92 |
tokio-rs/tokio:tokio/src/util/future.rs:3 | mod test {
use super::*;
use crate::prelude::future;
#[cfg(feature = "timer")]
#[test]
fn timeout_polls_at_least_once() {
let base_future = future::result::<(), ()>(Ok(()));
let timeouted_future = base_future.timeout(Duration::new(0, 0));
assert!(timeouted_future.wait().is_o... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/future.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/src/util/future.rs | 81 | 92 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:1 | //! This module defines an `IdleNotifiedSet`, which is a collection of elements.
//! Each element is intended to correspond to a task, and the collection will
//! keep track of which tasks have had their waker notified, and which have not.
//!
//! Each entry in the set holds some user-specified value. The value's type ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:2 | }
type Lists<T> = Mutex<ListsInner<T>>;
/// The linked lists hold strong references to the `ListEntry` items, and the
/// `ListEntry` items also hold a strong reference back to the Lists object, but
/// the destructor of the `IdleNotifiedSet` will clear the two lists, so once
/// that object is destroyed, no ref-cycl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:3 | /// must only be accessed while holding the mutex. If the value of `my_list` is
/// `Neither`, then the `pointers` field may be accessed by the
/// `IdleNotifiedSet` (this happens inside `drain`).
///
/// The `value` field is owned by the `IdleNotifiedSet` and may only be accessed
/// by the `IdleNotifiedSet`. The oper... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:4 | // not allow access to the value in any way (including its destructor), it is
// not necessary for `T` to be Send or Sync.
unsafe impl<T> Send for ListEntry<T> {}
unsafe impl<T> Sync for ListEntry<T> {}
impl<T> IdleNotifiedSet<T> {
/// Create a new `IdleNotifiedSet`.
pub(crate) fn new() -> Self {
let l... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:5 | {
let mut lock = self.lists.lock();
lock.idle.push_front(entry.clone());
}
// Safety: We just put the entry in the idle list, so it is in one of the lists.
EntryInOneOfTheLists { entry, set: self }
}
/// Pop an entry from the notified list to poll it. The entry ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:6 | // Safety: We just put the entry in the idle list, so it is in one of the lists.
Some(EntryInOneOfTheLists { entry, set: self })
}
/// Tries to pop an entry from the notified list to poll it. The entry is moved to
/// the idle list atomically.
pub(crate) fn try_pop_notified(&mut self) -> Option... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:7 | let ptr: *mut ManuallyDrop<T> = ptr;
let ptr: *mut T = ptr.cast();
ptr
}));
let prev = entry.pointers.get_prev();
node = prev.map(|prev| unsafe { &*prev.as_ptr() });
}
}
// Atomically get a raw pointer ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:8 | pub(crate) fn drain<F: FnMut(T)>(&mut self, func: F) {
if self.length == 0 {
// Fast path.
return;
}
self.length = 0;
// The LinkedList is not cleared on panic, so we use a bomb to clear it.
//
// This value has the invariant that any entry in its... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:9 | func,
};
// Atomically move all entries to the new linked list in the AllEntries
// object.
{
let mut lock = self.lists.lock();
unsafe {
// Safety: We are holding the lock and `all_entries` is a new
// LinkedList.
m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:10 | impl<'a, T> EntryInOneOfTheLists<'a, T> {
/// Remove this entry from the list it is in, returning the value associated
/// with the entry.
///
/// This consumes the value, since it is no longer guaranteed to be in a
/// list.
pub(crate) fn remove(self) -> T {
self.set.length -= 1;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:11 | .value
.with_mut(|ptr| unsafe { ManuallyDrop::take(&mut *ptr) })
}
/// Access the value in this entry together with a context for its waker.
pub(crate) fn with_value_and_context<F, U>(&mut self, func: F) -> U
where
F: FnOnce(&mut T, &mut Context<'_>) -> U,
T: 'static,
{
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:12 | // Safety: We are holding the lock and we will update the lists to
// maintain invariants.
let old_my_list = me.my_list.with_mut(|ptr| unsafe {
let old_my_list = *ptr;
if old_my_list == List::Idle {
*ptr = List::Notified;
}
old_my_list
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:13 | unsafe { NonNull::new_unchecked(ptr as *mut ListEntry<T>) }
}
unsafe fn from_raw(ptr: NonNull<ListEntry<T>>) -> Arc<ListEntry<T>> {
unsafe { Arc::from_raw(ptr.as_ptr()) }
}
unsafe fn pointers(
target: NonNull<ListEntry<T>>,
) -> NonNull<linked_list::Pointers<ListEntry<T>>> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/idle_notified_set.rs | 481 | 512 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:9 | func,
};
// Atomically move all entries to the new linked list in the AllEntries
// object.
{
let mut lock = self.lists.lock();
unsafe {
// Safety: We are holding the lock and `all_entries` is a new
// LinkedList.
m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/idle_notified_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:10 | ///
/// This consumes the value, since it is no longer guaranteed to be in a
/// list.
pub(crate) fn remove(self) -> T {
self.set.length -= 1;
{
let mut lock = self.set.lists.lock();
// Safety: We are holding the lock so there is no race, and we will
// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/idle_notified_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:11 | /// Access the value in this entry together with a context for its waker.
pub(crate) fn with_value_and_context<F, U>(&mut self, func: F) -> U
where
F: FnOnce(&mut T, &mut Context<'_>) -> U,
T: 'static,
{
let waker = waker_ref(&self.entry);
let mut context = Context::from_wak... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/idle_notified_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:12 | let old_my_list = *ptr;
if old_my_list == List::Idle {
*ptr = List::Notified;
}
old_my_list
});
if old_my_list == List::Idle {
// We move ourself to the notified list.
let me = unsafe {
// Safety: We just checke... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/idle_notified_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:13 | unsafe fn from_raw(ptr: NonNull<ListEntry<T>>) -> Arc<ListEntry<T>> {
Arc::from_raw(ptr.as_ptr())
}
unsafe fn pointers(
target: NonNull<ListEntry<T>>,
) -> NonNull<linked_list::Pointers<ListEntry<T>>> {
ListEntry::addr_of_pointers(target)
}
}
#[cfg(all(test, not(loom)))]
mod te... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/idle_notified_set.rs | 481 | 509 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:1 | //! This module defines an `IdleNotifiedSet`, which is a collection of elements.
//! Each element is intended to correspond to a task, and the collection will
//! keep track of which tasks have had their waker notified, and which have not.
//!
//! Each entry in the set holds some user-specified value. The value's type ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 12ce924fb9c1ffe0340b979fefa00d13ebf631c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12ce924fb9c1ffe0340b979fefa00d13ebf631c3/tokio/src/util/idle_notified_set.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:2 | }
type Lists<T> = Mutex<ListsInner<T>>;
/// The linked lists hold strong references to the ListEntry items, and the
/// ListEntry items also hold a strong reference back to the Lists object, but
/// the destructor of the `IdleNotifiedSet` will clear the two lists, so once
/// that object is destroyed, no ref-cycles w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 12ce924fb9c1ffe0340b979fefa00d13ebf631c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12ce924fb9c1ffe0340b979fefa00d13ebf631c3/tokio/src/util/idle_notified_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:5 | {
let mut lock = self.lists.lock();
lock.idle.push_front(entry.clone());
}
// Safety: We just put the entry in the idle list, so it is in one of the lists.
EntryInOneOfTheLists { entry, set: self }
}
/// Pop an entry from the notified list to poll it. The entry ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/util/idle_notified_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:6 | // Safety: We just put the entry in the idle list, so it is in one of the lists.
Some(EntryInOneOfTheLists { entry, set: self })
}
/// Call a function on every element in this list.
pub(crate) fn for_each<F: FnMut(&mut T)>(&mut self, mut func: F) {
fn get_ptrs<T>(list: &mut LinkedList<T>, p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/util/idle_notified_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:7 | // and it must still be valid because we are the IdleNotifiedSet,
// and only we can remove an entry from the two lists. (It's
// possible that an entry is moved from one list to the other during
// this loop, but that is ok.)
func(unsafe { &mut *ptr });
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/util/idle_notified_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:8 | }
}
}
impl<T, F: FnMut(T)> Drop for AllEntries<T, F> {
fn drop(&mut self) {
while self.pop_next() {}
}
}
let mut all_entries = AllEntries {
all_entries: LinkedList::new(),
func,
};
// Atomicall... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/util/idle_notified_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:9 | unsafe fn move_to_new_list<T>(from: &mut LinkedList<T>, to: &mut LinkedList<T>) {
while let Some(entry) = from.pop_back() {
entry.my_list.with_mut(|ptr| {
*ptr = List::Neither;
});
to.push_front(entry);
}
}
impl<'a, T> EntryInOneOfTheLists<'a, T> {
/// Remove this entry ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/util/idle_notified_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:10 | }
}
// By setting `my_list` to `Neither`, we have taken ownership of the
// value. We return it to the caller.
//
// Safety: We have a mutable reference to the `IdleNotifiedSet` that
// owns this entry, so we can use its permission to access the value.
self.entry... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/util/idle_notified_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:11 | assert!(lock.notified.is_empty());
}
}
}
impl<T: 'static> Wake for ListEntry<T> {
fn wake_by_ref(me: &Arc<Self>) {
let mut lock = me.parent.lock();
// Safety: We are holding the lock and we will update the lists to
// maintain invariants.
let old_my_list = me.my_list.wi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/util/idle_notified_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:12 | ///
/// `ListEntry` is forced to be !Unpin.
unsafe impl<T> linked_list::Link for ListEntry<T> {
type Handle = Arc<ListEntry<T>>;
type Target = ListEntry<T>;
fn as_raw(handle: &Self::Handle) -> NonNull<ListEntry<T>> {
let ptr: *const ListEntry<T> = Arc::as_ptr(handle);
// Safety: We can't ge... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/util/idle_notified_set.rs | 441 | 481 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:3 | /// must only be accessed while holding the mutex. If the value of `my_list` is
/// `Neither`, then the `pointers` field may be accessed by the
/// `IdleNotifiedSet` (this happens inside `drain`).
///
/// The `value` field is owned by the `IdleNotifiedSet` and may only be accessed
/// by the `IdleNotifiedSet`. The oper... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1014262d34021f219f1fba88b78899ee29b9c943 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1014262d34021f219f1fba88b78899ee29b9c943/tokio/src/util/idle_notified_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:4 | // not allow access to the value in any way (including its destructor), it is
// not necessary for `T` to be Send or Sync.
unsafe impl<T> Send for ListEntry<T> {}
unsafe impl<T> Sync for ListEntry<T> {}
impl<T> IdleNotifiedSet<T> {
/// Create a new IdleNotifiedSet.
pub(crate) fn new() -> Self {
let lis... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1014262d34021f219f1fba88b78899ee29b9c943 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1014262d34021f219f1fba88b78899ee29b9c943/tokio/src/util/idle_notified_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:11 | assert!(lock.notified.is_empty());
}
}
}
impl<T: 'static> Wake for ListEntry<T> {
fn wake_by_ref(me: &Arc<Self>) {
let mut lock = me.parent.lock();
// Safety: We are holding the lock and we will update the lists to
// maintain invariants.
let old_my_list = me.my_list.wi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1014262d34021f219f1fba88b78899ee29b9c943 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1014262d34021f219f1fba88b78899ee29b9c943/tokio/src/util/idle_notified_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:12 | ///
/// `ListEntry` is forced to be !Unpin.
unsafe impl<T> linked_list::Link for ListEntry<T> {
type Handle = Arc<ListEntry<T>>;
type Target = ListEntry<T>;
fn as_raw(handle: &Self::Handle) -> NonNull<ListEntry<T>> {
let ptr: *const ListEntry<T> = Arc::as_ptr(handle);
// Safety: We can't ge... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | f6313f4382145a365dfd94a352a53f805a2f14ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f6313f4382145a365dfd94a352a53f805a2f14ef/tokio/src/util/idle_notified_set.rs | 441 | 481 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:11 | assert!(lock.notified.is_empty());
}
}
}
impl<T: 'static> Wake for ListEntry<T> {
fn wake_by_ref(me: &Arc<Self>) {
let mut lock = me.parent.lock();
// Safety: We are holding the lock and we will update the lists to
// maintain invariants.
let old_my_list = me.my_list.wi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6f048ca954aa5f285f1cf6310d447e7c079c1c3d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/util/idle_notified_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:12 | ///
/// `ListEntry` is forced to be !Unpin.
unsafe impl<T> linked_list::Link for ListEntry<T> {
type Handle = Arc<ListEntry<T>>;
type Target = ListEntry<T>;
fn as_raw(handle: &Self::Handle) -> NonNull<ListEntry<T>> {
let ptr: *const ListEntry<T> = Arc::as_ptr(handle);
// Safety: We can't ge... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 6f048ca954aa5f285f1cf6310d447e7c079c1c3d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/util/idle_notified_set.rs | 441 | 462 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:2 | }
type Lists<T> = Mutex<ListsInner<T>>;
/// The linked lists hold strong references to the ListEntry items, and the
/// ListEntry items also hold a strong reference back to the Lists object, but
/// the destructor of the `IdleNotifiedSet` will clear the two lists, so once
/// that object is destroyed, no ref-cycles w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:3 | /// must only be accessed while holding the mutex. If the value of `my_list` is
/// `Neither`, then the `pointers` field may be accessed by the
/// `IdleNotifiedSet` (this happens inside `drain`).
///
/// The `value` field is owned by the `IdleNotifiedSet` and may only be accessed
/// by the `IdleNotifiedSet`. The oper... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:4 | impl<T> IdleNotifiedSet<T> {
/// Create a new IdleNotifiedSet.
pub(crate) fn new() -> Self {
let lists = Mutex::new(ListsInner {
notified: LinkedList::new(),
idle: LinkedList::new(),
waker: None,
});
IdleNotifiedSet {
lists: Arc::new(lists... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:5 | // Safety: We just put the entry in the idle list, so it is in one of the lists.
EntryInOneOfTheLists { entry, set: self }
}
/// Pop an entry from the notified list to poll it. The entry is moved to
/// the idle list atomically.
pub(crate) fn pop_notified(&mut self, waker: &Waker) -> Option<Ent... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:6 | /// Call a function on every element in this list.
pub(crate) fn for_each<F: FnMut(&mut T)>(&mut self, mut func: F) {
fn get_ptrs<T>(list: &mut LinkedList<T>, ptrs: &mut Vec<*mut T>) {
let mut node = list.last();
while let Some(entry) = node {
ptrs.push(entry.value.w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:7 | func(unsafe { &mut *ptr });
}
}
/// Remove all entries in both lists, applying some function to each element.
///
/// The closure is called on all elements even if it panics. Having it panic
/// twice is a double-panic, and will abort the application.
pub(crate) fn drain<F: FnMut(T)>(&m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:8 | impl<T, F: FnMut(T)> Drop for AllEntries<T, F> {
fn drop(&mut self) {
while self.pop_next() {}
}
}
let mut all_entries = AllEntries {
all_entries: LinkedList::new(),
func,
};
// Atomically move all entries to the new linke... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:9 | });
to.push_front(entry);
}
}
impl<'a, T> EntryInOneOfTheLists<'a, T> {
/// Remove this entry from the list it is in, returning the value associated
/// with the entry.
///
/// This consumes the value, since it is no longer guaranteed to be in a
/// list.
pub(crate) fn remove(self) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:10 | // value. We return it to the caller.
//
// Safety: We have a mutable reference to the `IdleNotifiedSet` that
// owns this entry, so we can use its permission to access the value.
self.entry
.value
.with_mut(|ptr| unsafe { ManuallyDrop::take(&mut *ptr) })
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:11 | impl<T: 'static> Wake for ListEntry<T> {
fn wake_by_ref(me: &Arc<Self>) {
let mut lock = me.parent.lock();
// Safety: We are holding the lock and we will update the lists to
// maintain invariants.
let old_my_list = me.my_list.with_mut(|ptr| unsafe {
let old_my_list = *p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/idle_notified_set.rs:12 | type Target = ListEntry<T>;
fn as_raw(handle: &Self::Handle) -> NonNull<ListEntry<T>> {
let ptr: *const ListEntry<T> = Arc::as_ptr(handle);
// Safety: We can't get a null pointer from `Arc::as_ptr`.
unsafe { NonNull::new_unchecked(ptr as *mut ListEntry<T>) }
}
unsafe fn from_raw(pt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/idle_notified_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/util/idle_notified_set.rs | 441 | 463 |
tokio-rs/tokio:tokio/src/util/intrusive_double_linked_list.rs:6 | // Safety: When the node was inserted it was promised that it is alive
// until it gets removed from the list
unsafe {
let mut tail = self.tail?;
self.tail = tail.as_mut().prev;
let last_ref = tail.as_mut();
match last_ref.prev {
None => {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/util/intrusive_double_linked_list.rs | MIT | 187af2e6a323be4193c82ad95f9aa32d2ae16869 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/187af2e6a323be4193c82ad95f9aa32d2ae16869/tokio/src/util/intrusive_double_linked_list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:1 | #![cfg_attr(not(feature = "full"), allow(dead_code))]
// It doesn't make sense to enforce `unsafe_op_in_unsafe_fn` for this module because
//
// * The intrusive linked list naturally relies on unsafe operations.
// * Excessive `unsafe {}` blocks hurt readability significantly.
// TODO: replace with `#[expect(unsafe_op_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:2 | ///
/// In order to support storing a single type within multiple lists, accessing
/// the list pointers is decoupled from the entry type.
///
/// # Safety
///
/// Implementations must guarantee that `Target` types are pinned in memory. In
/// other words, when a node is inserted, the value will not be moved as long as... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:3 | inner: UnsafeCell<PointersInner<T>>,
}
/// We do not want the compiler to put the `noalias` attribute on mutable
/// references to this type, so the type has been made `!Unpin` with a
/// `PhantomPinned` field.
///
/// Additionally, we never access the `prev` or `next` fields directly, as any
/// such access would impl... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:4 | _marker: PhantomData,
}
}
}
impl<L: Link> LinkedList<L, L::Target> {
/// Adds an element first in the list.
pub(crate) fn push_front(&mut self, val: L::Handle) {
// The value should not be dropped, it is being inserted into the list
let val = ManuallyDrop::new(val);
let ptr ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:5 | L::pointers(head).as_mut().set_prev(None);
L::pointers(head).as_mut().set_next(None);
Some(L::from_raw(head))
}
}
/// Removes the last element from a list and returns it, or None if it is
/// empty.
pub(crate) fn pop_back(&mut self) -> Option<L::Handle> {
unsafe... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:6 | /// # Safety
///
/// The caller **must** ensure that exactly one of the following is true:
/// - `node` is currently contained by `self`,
/// - `node` is not contained by any list,
/// - `node` is currently contained by some other `GuardedLinkedList` **and**
/// the caller has an exclusive acc... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:7 | }
}
impl<L: Link> fmt::Debug for LinkedList<L, L::Target> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("LinkedList")
.field("head", &self.head)
.field("tail", &self.tail)
.finish()
}
}
#[cfg(any(
feature = "fs",
feature = "rt",... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:8 | impl<T: Link> LinkedList<T, T::Target> {
pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F>
where
F: FnMut(&T::Target) -> bool,
{
let curr = self.head;
DrainFilter {
curr,
filter,
list: ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:9 | pub(crate) fn for_each<F>(&mut self, mut f: F)
where
F: FnMut(&T::Handle),
{
let mut next = self.head;
while let Some(curr) = next {
unsafe {
let handle = ManuallyDrop::new(T::from_raw(curr));
f(&handle);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:10 | }
impl<L: Link> LinkedList<L, L::Target> {
/// Turns a linked list into the guarded version by linking the guard node
/// with the head and tail nodes. Like with other nodes, you should guarantee
/// that the guard node is pinned in memory.
pub(crate) fn into_guarded(self, guard_han... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:11 | // the list is considered empty.
if tail_ptr != self.guard {
Some(tail_ptr)
} else {
None
}
}
/// Removes the last element from a list and returns it, or None if it is
/// empty.
pub(crate) fn pop_back(&mut self) -> Opt... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:12 | pub(crate) fn get_prev(&self) -> Option<NonNull<T>> {
// SAFETY: Field is accessed immutably through a reference.
unsafe { ptr::addr_of!((*self.inner.get()).prev).read() }
}
pub(crate) fn get_next(&self) -> Option<NonNull<T>> {
// SAFETY: Field is accessed immutably through a reference.
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:13 | use std::pin::Pin;
#[derive(Debug)]
#[repr(C)]
struct Entry {
pointers: Pointers<Entry>,
val: i32,
}
unsafe impl<'a> Link for &'a Entry {
type Handle = Pin<&'a Entry>;
type Target = Entry;
fn as_raw(handle: &Pin<&'_ Entry>) -> NonNull<Entry> {
N... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:14 | while let Some(entry) = list.pop_back() {
ret.push(entry.val);
}
ret
}
fn push_all<'a>(
list: &mut LinkedList<&'a Entry, <&'_ Entry as Link>::Target>,
entries: &[Pin<&'a Entry>],
) {
for entry in entries.iter() {
list.push_front(*entry);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:15 | let b = entry(7);
let c = entry(31);
let mut list = LinkedList::new();
assert!(list.is_empty());
list.push_front(a.as_ref());
assert!(!list.is_empty());
list.push_front(b.as_ref());
list.push_front(c.as_ref());
let items: Vec<i32> = collect_list(&mut li... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:16 | fn remove_by_address() {
let a = entry(5);
let b = entry(7);
let c = entry(31);
unsafe {
// Remove first
let mut list = LinkedList::new();
push_all(&mut list, &[c.as_ref(), b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some())... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:17 | assert_ptr_eq!(b, c.pointers.get_prev());
let items = collect_list(&mut list);
assert_eq!([31, 7].to_vec(), items);
}
unsafe {
// Remove middle
let mut list = LinkedList::new();
push_all(&mut list, &[c.as_ref(), b.as_ref(), a.as_ref()]);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:18 | // Remove first of two
let mut list = LinkedList::new();
push_all(&mut list, &[b.as_ref(), a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
// a should be no longer there and can't be removed twice
assert!(list.remove(pt... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/util/linked_list.rs:19 | }
unsafe {
// Remove last item
let mut list = LinkedList::new();
push_all(&mut list, &[a.as_ref()]);
assert!(list.remove(ptr(&a)).is_some());
assert_clean!(a);
assert!(list.head.is_none());
assert!(list.tail.is_none());
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/util/linked_list.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/linked_list.rs | 721 | 780 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.