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/time/driver/sleep.rs:1 | use crate::time::driver::{Handle, TimerEntry};
use crate::time::{error::Error, Duration, Instant};
use crate::util::trace;
use pin_project_lite::pin_project;
use std::future::Future;
use std::panic::Location;
use std::pin::Pin;
use std::task::{self, Poll};
cfg_trace! {
use crate::time::driver::ClockTime;
}
/// W... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | b9834f6d8b3563e6907456d19fe418cfe19983c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9834f6d8b3563e6907456d19fe418cfe19983c3/tokio/src/time/driver/sleep.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:2 | ///
/// See the documentation for the [`Sleep`] type for more examples.
///
/// [`Sleep`]: struct@crate::time::Sleep
/// [`interval`]: crate::time::interval()
// Alias for old name in 0.x
#[cfg_attr(docsrs, doc(alias = "delay_until"))]
#[cfg_attr(tokio_track_caller, track_caller)]
pub fn sleep_until(deadline: Instant) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | b9834f6d8b3563e6907456d19fe418cfe19983c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9834f6d8b3563e6907456d19fe418cfe19983c3/tokio/src/time/driver/sleep.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:6 | }
cfg_trace! {
#[derive(Debug)]
struct Inner {
deadline: Instant,
resource_span: tracing::Span,
async_op_span: tracing::Span,
time_source: ClockTime,
}
}
cfg_not_trace! {
#[derive(Debug)]
struct Inner {
deadline: Instant,
}
}
impl Sleep {
#[cfg_attr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | b9834f6d8b3563e6907456d19fe418cfe19983c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9834f6d8b3563e6907456d19fe418cfe19983c3/tokio/src/time/driver/sleep.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:7 | concrete_type = "Sleep",
kind = "timer",
loc.file = location.file(),
loc.line = location.line(),
loc.col = location.column(),
);
#[cfg(not(tokio_track_caller))]
let resource_span =
tracing::trace_span!("... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | b9834f6d8b3563e6907456d19fe418cfe19983c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9834f6d8b3563e6907456d19fe418cfe19983c3/tokio/src/time/driver/sleep.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:8 | /// Returns the instant at which the future will complete.
pub fn deadline(&self) -> Instant {
self.inner.deadline
}
/// Returns `true` if `Sleep` has elapsed.
///
/// A `Sleep` instance is elapsed when the requested duration has elapsed.
pub fn is_elapsed(&self) -> bool {
self.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | b9834f6d8b3563e6907456d19fe418cfe19983c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9834f6d8b3563e6907456d19fe418cfe19983c3/tokio/src/time/driver/sleep.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:9 | /// [`Pin::as_mut`]: fn@std::pin::Pin::as_mut
pub fn reset(self: Pin<&mut Self>, deadline: Instant) {
self.reset_inner(deadline)
}
fn reset_inner(self: Pin<&mut Self>, deadline: Instant) {
let me = self.project();
me.entry.reset(deadline);
(*me.inner).deadline = deadline;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | b9834f6d8b3563e6907456d19fe418cfe19983c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9834f6d8b3563e6907456d19fe418cfe19983c3/tokio/src/time/driver/sleep.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:10 | }
}
cfg_trace! {
fn poll_elapsed(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Result<(), Error>> {
let me = self.project();
// Keep track of task budget
let coop = ready!(trace_poll_op!(
"poll_elapsed",
crate::coop::poll_p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | b9834f6d8b3563e6907456d19fe418cfe19983c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9834f6d8b3563e6907456d19fe418cfe19983c3/tokio/src/time/driver/sleep.rs | 361 | 405 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:4 | /// impl Future for HasSleep {
/// type Output = ();
///
/// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
/// self.sleep.as_mut().poll(cx)
/// }
/// }
/// ```
/// Use in a struct with pin projection. This method avoids the `Box`, but
/// t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | ab0791b8175d85dd49be063400a211f0790dd6a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ab0791b8175d85dd49be063400a211f0790dd6a9/tokio/src/time/driver/sleep.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:5 | deadline: Instant,
// The link between the `Sleep` instance and the timer that drives it.
#[pin]
entry: TimerEntry,
}
}
impl Sleep {
pub(crate) fn new_timeout(deadline: Instant) -> Sleep {
let handle = Handle::current();
let entry = TimerEntry::new(&handle, deadline);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | ab0791b8175d85dd49be063400a211f0790dd6a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ab0791b8175d85dd49be063400a211f0790dd6a9/tokio/src/time/driver/sleep.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:6 | /// To call this method, you will usually combine the call with
/// [`Pin::as_mut`], which lets you call the method without consuming the
/// `Sleep` itself.
///
/// # Example
///
/// ```
/// use tokio::time::{Duration, Instant};
///
/// # #[tokio::main(flavor = "current_thread")]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | ab0791b8175d85dd49be063400a211f0790dd6a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ab0791b8175d85dd49be063400a211f0790dd6a9/tokio/src/time/driver/sleep.rs | 201 | 257 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:7 | fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// `poll_elapsed` can return an error in two cases:
//
// - AtCapacity: this is a pathological case where far too many
// sleep instances have been scheduled.
// - Shutdown: No timer has been ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | ab0791b8175d85dd49be063400a211f0790dd6a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ab0791b8175d85dd49be063400a211f0790dd6a9/tokio/src/time/driver/sleep.rs | 241 | 257 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:4 | /// type Output = ();
///
/// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
/// self.sleep.as_mut().poll(cx)
/// }
/// }
/// ```
/// Use in a struct with pin projection. This method avoids the `Box`, but
/// the `HasSleep` struct will not be `U... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | 1cda0f16a2f8814e0a973162543d6d1f786c8a44 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cda0f16a2f8814e0a973162543d6d1f786c8a44/tokio/src/time/driver/sleep.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:5 | // The link between the `Sleep` instance and the timer that drives it.
#[pin]
entry: TimerEntry,
}
}
impl Sleep {
pub(crate) fn new_timeout(deadline: Instant) -> Sleep {
let handle = Handle::current();
let entry = TimerEntry::new(&handle, deadline);
Sleep { deadline, en... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | 1cda0f16a2f8814e0a973162543d6d1f786c8a44 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cda0f16a2f8814e0a973162543d6d1f786c8a44/tokio/src/time/driver/sleep.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:6 | /// [`Pin::as_mut`], which lets you call the method without consuming the
/// `Sleep` itself.
///
/// # Example
///
/// ```
/// use tokio::time::{Duration, Instant};
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let sleep = tokio::time::sleep(Dur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | 1cda0f16a2f8814e0a973162543d6d1f786c8a44 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cda0f16a2f8814e0a973162543d6d1f786c8a44/tokio/src/time/driver/sleep.rs | 201 | 256 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:4 | /// type Output = ();
///
/// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
/// self.sleep.as_mut().poll(cx)
/// }
/// }
/// ```
/// Use in a struct with pin projection. This method avoids the `Box`, but
/// the `HasSleep` struct will not be `U... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | d2ad7afd21e4faef05ccccb0288bc814a954b990 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2ad7afd21e4faef05ccccb0288bc814a954b990/tokio/src/time/driver/sleep.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:5 | #[pin]
entry: TimerEntry,
}
}
impl Sleep {
pub(crate) fn new_timeout(deadline: Instant) -> Sleep {
let handle = Handle::current();
let entry = TimerEntry::new(&handle, deadline);
Sleep { deadline, entry }
}
pub(crate) fn far_future() -> Sleep {
Self::new_timeou... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | d2ad7afd21e4faef05ccccb0288bc814a954b990 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2ad7afd21e4faef05ccccb0288bc814a954b990/tokio/src/time/driver/sleep.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:6 | ///
/// # Example
///
/// ```
/// use tokio::time::{Duration, Instant};
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let sleep = tokio::time::sleep(Duration::from_millis(10));
/// tokio::pin!(sleep);
///
/// sleep.as_mut().reset(Instant::now... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | d2ad7afd21e4faef05ccccb0288bc814a954b990 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2ad7afd21e4faef05ccccb0288bc814a954b990/tokio/src/time/driver/sleep.rs | 201 | 254 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:7 | //
// - AtCapacity: this is a pathological case where far too many
// sleep instances have been scheduled.
// - Shutdown: No timer has been setup, which is a mis-use error.
//
// Both cases are extremely rare, and pretty accurately fit into
// "logic errors", so we just... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | d2ad7afd21e4faef05ccccb0288bc814a954b990 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d2ad7afd21e4faef05ccccb0288bc814a954b990/tokio/src/time/driver/sleep.rs | 241 | 254 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:2 | /// # Examples
///
/// Wait 100ms and print "100 ms have elapsed".
///
/// ```
/// use tokio::time::{sleep, Duration};
///
/// #[tokio::main]
/// async fn main() {
/// sleep(Duration::from_millis(100)).await;
/// println!("100 ms have elapsed");
/// }
/// ```
///
/// [`interval`]: crate::time::interval()
pub fn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | d74d17307dd53215061c4a8a1f20a0e30461e296 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d74d17307dd53215061c4a8a1f20a0e30461e296/tokio/src/time/driver/sleep.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:3 | /// Returns the instant at which the future will complete.
pub fn deadline(&self) -> Instant {
self.deadline
}
/// Returns `true` if `Sleep` has elapsed.
///
/// A `Sleep` instance is elapsed when the requested duration has elapsed.
pub fn is_elapsed(&self) -> bool {
self.entry.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | d74d17307dd53215061c4a8a1f20a0e30461e296 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d74d17307dd53215061c4a8a1f20a0e30461e296/tokio/src/time/driver/sleep.rs | 81 | 138 |
tokio-rs/tokio:tokio/src/time/driver/sleep.rs:4 | type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// `poll_elapsed` can return an error in two cases:
//
// - AtCapacity: this is a pathological case where far too many
// sleep instances have been scheduled.
// - Shutd... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/sleep.rs | MIT | d74d17307dd53215061c4a8a1f20a0e30461e296 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d74d17307dd53215061c4a8a1f20a0e30461e296/tokio/src/time/driver/sleep.rs | 121 | 138 |
tokio-rs/tokio:tokio/src/time/driver/stack.rs:1 | use crate::time::driver::Entry;
use crate::time::wheel;
use std::ptr;
use std::sync::Arc;
/// A doubly linked stack
#[derive(Debug)]
pub(crate) struct Stack {
head: Option<Arc<Entry>>,
}
impl Default for Stack {
fn default() -> Stack {
Stack { head: None }
}
}
impl wheel::Stack for Stack {
t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/stack.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/driver/stack.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/stack.rs:2 | debug_assert!({
// The head is not already set to the entry
ptr != &***entry as *const _
});
// Set the previous link on the old head
*entry.prev_stack.get() = ptr;
}
// Set this entry's next pointer
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/stack.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/driver/stack.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/stack.rs:3 | // This walks the full linked list even if an entry is found.
let mut next = self.head.as_ref();
let mut contains = false;
while let Some(n) = next {
if entry as *const _ == &**n as *const _ {
debug_assert!(!contains);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/stack.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/driver/stack.rs | 81 | 121 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | #![cfg(not(tokio_wasi))]
use std::{task::Context, time::Duration};
#[cfg(not(loom))]
use futures::task::noop_waker_ref;
use crate::loom::sync::Arc;
use crate::loom::thread;
use crate::{
loom::sync::atomic::{AtomicBool, Ordering},
park::Unpark,
};
use super::{Handle, TimerEntry};
struct MockUnpark {}
impl U... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/time/driver/tests/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:2 | #[cfg(loom)]
loom::model(f);
#[cfg(not(loom))]
f();
}
#[test]
fn single_timer() {
model(|| {
let clock = crate::time::clock::Clock::new(true, false);
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source.clone(), MockUnpark::mock());... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/time/driver/tests/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:3 | model(|| {
let clock = crate::time::clock::Clock::new(true, false);
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source.clone(), MockUnpark::mock());
let handle = Handle::new(Arc::new(inner));
let handle_ = handle.clone();
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/time/driver/tests/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:4 | let entry = TimerEntry::new(&handle_, clock.now() + Duration::from_secs(1));
pin!(entry);
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_ref()));
block_on(futures::future::poll_fn(|cx| {
entry... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/time/driver/tests/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:5 | let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_ref()));
entry.as_mut().reset(start + Duration::from_secs(2));
// shouldn't complete before 2s
block_on(futures::future::poll_fn(|cx| {
entry.as_... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/time/driver/tests/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:6 | #[test]
#[cfg(not(loom))]
fn poll_process_levels() {
let clock = crate::time::clock::Clock::new(true, false);
clock.pause();
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source, MockUnpark::mock());
let handle = Handle::new(Arc::new(inner));
let m... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/time/driver/tests/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:7 | #[cfg(not(loom))]
fn poll_process_levels_targeted() {
let mut context = Context::from_waker(noop_waker_ref());
let clock = crate::time::clock::Clock::new(true, false);
clock.pause();
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source, MockUnpark::moc... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/time/driver/tests/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:8 | thread::yield_now();
}
}
loom::model(|| {
let unpark = Box::new(MockUnpark);
let instant = Instant::now();
let inner = Arc::new(Inner::new(instant, unpark));
let incr_inner = inner.clone();
let decr_inner = inner.clone();
let incr_handle = thread::spaw... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/time/driver/tests/mod.rs | 281 | 303 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | #![cfg(not(target_os = "wasi"))]
use std::{task::Context, time::Duration};
#[cfg(not(loom))]
use futures::task::noop_waker_ref;
use crate::loom::sync::Arc;
use crate::loom::thread;
use crate::{
loom::sync::atomic::{AtomicBool, Ordering},
park::Unpark,
};
use super::{Handle, TimerEntry};
struct MockUnpark {... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | f3e340a35b306e926e78537a0dd65b2e9b9cdc89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/time/driver/tests/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:7 | #[cfg(not(loom))]
fn poll_process_levels_targeted() {
let mut context = Context::from_waker(noop_waker_ref());
let clock = crate::time::clock::Clock::new(true, false);
clock.pause();
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source, MockUnpark::moc... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/src/time/driver/tests/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:8 | thread::yield_now();
}
}
loom::model(|| {
let unpark = Box::new(MockUnpark);
let instant = Instant::now();
let inner = Arc::new(Inner::new(instant, unpark));
let incr_inner = inner.clone();
let decr_inner = inner.clone();
let incr_hndle = thread::spawn... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/src/time/driver/tests/mod.rs | 281 | 303 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | use std::{task::Context, time::Duration};
#[cfg(not(loom))]
use futures::task::noop_waker_ref;
use crate::loom::sync::Arc;
use crate::loom::thread;
use crate::{
loom::sync::atomic::{AtomicBool, Ordering},
park::Unpark,
};
use super::{Handle, TimerEntry};
struct MockUnpark {}
impl Unpark for MockUnpark {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/time/driver/tests/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:2 | #[cfg(not(loom))]
f();
}
#[test]
fn single_timer() {
model(|| {
let clock = crate::time::clock::Clock::new(true, false);
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source.clone(), MockUnpark::mock());
let handle = Handle::new(Arc:... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/time/driver/tests/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:3 | let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source.clone(), MockUnpark::mock());
let handle = Handle::new(Arc::new(inner));
let handle_ = handle.clone();
let jh = thread::spawn(move || {
let entry = TimerEntry::new(&handle_, cl... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/time/driver/tests/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:4 | let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_ref()));
block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
});
thread::yield_now();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/time/driver/tests/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:5 | .as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_ref()));
entry.as_mut().reset(start + Duration::from_secs(2));
// shouldn't complete before 2s
block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/time/driver/tests/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:6 | fn poll_process_levels() {
let clock = crate::time::clock::Clock::new(true, false);
clock.pause();
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source, MockUnpark::mock());
let handle = Handle::new(Arc::new(inner));
let mut entries = vec![];
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/time/driver/tests/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:7 | let mut context = Context::from_waker(noop_waker_ref());
let clock = crate::time::clock::Clock::new(true, false);
clock.pause();
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source, MockUnpark::mock());
let handle = Handle::new(Arc::new(inner));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/time/driver/tests/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:8 | }
loom::model(|| {
let unpark = Box::new(MockUnpark);
let instant = Instant::now();
let inner = Arc::new(Inner::new(instant, unpark));
let incr_inner = inner.clone();
let decr_inner = inner.clone();
let incr_hndle = thread::spawn(move || incr(incr_inner));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/time/driver/tests/mod.rs | 281 | 301 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | use std::{task::Context, time::Duration};
#[cfg(not(loom))]
use futures::task::noop_waker_ref;
use crate::loom::sync::Arc;
use crate::loom::thread;
use crate::{
loom::sync::atomic::{AtomicBool, Ordering},
park::Unpark,
};
use super::{Handle, TimerEntry};
struct MockUnpark {}
impl Unpark for MockUnpark {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | c39d9867bb989396bb02e74d87f2805969f43f03 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/tests/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:2 | #[test]
fn single_timer() {
model(|| {
let clock = crate::time::clock::Clock::new(true, false);
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source.clone(), MockUnpark::mock());
let handle = Handle::new(Arc::new(inner));
let han... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | c39d9867bb989396bb02e74d87f2805969f43f03 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/tests/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:3 | let handle_ = handle.clone();
let jh = thread::spawn(move || {
let entry = TimerEntry::new(&handle_, clock.now() + Duration::from_secs(1));
pin!(entry);
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_r... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | c39d9867bb989396bb02e74d87f2805969f43f03 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/tests/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:4 | block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
});
thread::yield_now();
// advance 2s
handle.process_at_time(time_source.now() + 2_000_000_000);
jh.join().unwrap();
})
}
#[test]
fn reset_futu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | c39d9867bb989396bb02e74d87f2805969f43f03 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/tests/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:5 | // shouldn't complete before 2s
block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
finished_early_.store(true, Ordering::Relaxed);
});
thread::yield_now();
// This may or may not return a wake... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | c39d9867bb989396bb02e74d87f2805969f43f03 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/tests/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:6 | clock.now() + Duration::from_millis(i),
));
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(noop_waker_ref()));
entries.push(entry);
}
for t in 1..1024 {
handle.process_at_time(t as u64);
for (deadline, future) in entries.iter_mut... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | c39d9867bb989396bb02e74d87f2805969f43f03 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/tests/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:7 | assert!(e1.as_mut().poll_elapsed(&mut context).is_pending());
handle.process_at_time(192);
handle.process_at_time(192);
}
/*
#[test]
fn balanced_incr_and_decr() {
const OPS: usize = 5;
fn incr(inner: Arc<Inner>) {
for _ in 0..OPS {
inner.increment().expect("increment should not hav... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | c39d9867bb989396bb02e74d87f2805969f43f03 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/tests/mod.rs | 241 | 287 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | use std::{task::Context, time::Duration};
#[cfg(not(loom))]
use futures::task::noop_waker_ref;
use crate::loom::sync::{Arc, Mutex};
use crate::loom::thread;
use crate::{
loom::sync::atomic::{AtomicBool, Ordering},
park::Unpark,
};
use super::{Handle, TimerEntry};
struct MockUnpark {}
impl Unpark for MockUnp... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/tests/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:2 | #[test]
fn single_timer() {
model(|| {
let clock = crate::time::clock::Clock::new(true, false);
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source.clone(), MockUnpark::mock());
let handle = Handle::new(Arc::new(Mutex::new(inner)));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/tests/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:3 | let handle_ = handle.clone();
let jh = thread::spawn(move || {
let entry = TimerEntry::new(&handle_, clock.now() + Duration::from_secs(1));
pin!(entry);
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_r... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/tests/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:4 | block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
});
thread::yield_now();
// advance 2s
handle.process_at_time(time_source.now() + 2_000_000_000);
jh.join().unwrap();
})
}
#[test]
fn reset_futu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/tests/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:5 | // shouldn't complete before 2s
block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
finished_early_.store(true, Ordering::Relaxed);
});
thread::yield_now();
// This may or may not return a wake... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/tests/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:6 | clock.now() + Duration::from_millis(i),
));
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(noop_waker_ref()));
entries.push(entry);
}
for t in 1..1024 {
handle.process_at_time(t as u64);
for (deadline, future) in entries.iter_mut... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/tests/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | use std::{task::Context, time::Duration};
#[cfg(not(loom))]
use futures::task::noop_waker_ref;
use crate::loom::sync::{Arc, Mutex};
use crate::loom::thread;
use crate::{
loom::sync::atomic::{AtomicBool, Ordering},
park::Unpark,
};
use super::{Handle, TimerEntry};
struct MockUnpark {}
impl Unpark for MockUnp... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | abd4c0025539f142ec48a09e01430f7ee3b83214 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abd4c0025539f142ec48a09e01430f7ee3b83214/tokio/src/time/driver/tests/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:2 | #[test]
fn single_timer() {
model(|| {
let clock = crate::time::clock::Clock::new(true);
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source.clone(), MockUnpark::mock());
let handle = Handle::new(Arc::new(Mutex::new(inner)));
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | abd4c0025539f142ec48a09e01430f7ee3b83214 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abd4c0025539f142ec48a09e01430f7ee3b83214/tokio/src/time/driver/tests/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:3 | let handle_ = handle.clone();
let jh = thread::spawn(move || {
let entry = TimerEntry::new(&handle_, clock.now() + Duration::from_secs(1));
pin!(entry);
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_r... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | abd4c0025539f142ec48a09e01430f7ee3b83214 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abd4c0025539f142ec48a09e01430f7ee3b83214/tokio/src/time/driver/tests/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:4 | block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
});
thread::yield_now();
// advance 2s
handle.process_at_time(time_source.now() + 2_000_000_000);
jh.join().unwrap();
})
}
#[test]
fn reset_futu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | abd4c0025539f142ec48a09e01430f7ee3b83214 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abd4c0025539f142ec48a09e01430f7ee3b83214/tokio/src/time/driver/tests/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:5 | // shouldn't complete before 2s
block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
finished_early_.store(true, Ordering::Relaxed);
});
thread::yield_now();
// This may or may not return a wake... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | abd4c0025539f142ec48a09e01430f7ee3b83214 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abd4c0025539f142ec48a09e01430f7ee3b83214/tokio/src/time/driver/tests/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:6 | clock.now() + Duration::from_millis(i),
));
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(noop_waker_ref()));
entries.push(entry);
}
for t in 1..1024 {
handle.process_at_time(t as u64);
for (deadline, future) in entries.iter_mut... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | abd4c0025539f142ec48a09e01430f7ee3b83214 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abd4c0025539f142ec48a09e01430f7ee3b83214/tokio/src/time/driver/tests/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | use std::{task::Context, time::Duration};
#[cfg(not(loom))]
use futures::task::noop_waker_ref;
use crate::loom::sync::{Arc, Mutex};
use crate::loom::thread;
use crate::{
loom::sync::atomic::{AtomicBool, Ordering},
park::Unpark,
};
use super::{Handle, TimerEntry};
struct MockUnpark {}
impl Unpark for MockUnp... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/tests/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:2 | #[test]
fn single_timer() {
model(|| {
let clock = crate::time::clock::Clock::new();
let time_source = super::ClockTime::new(clock.clone());
let inner = super::Inner::new(time_source.clone(), MockUnpark::mock());
let handle = Handle::new(Arc::new(Mutex::new(inner)));
let ha... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/tests/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:3 | let handle_ = handle.clone();
let jh = thread::spawn(move || {
let entry = TimerEntry::new(&handle_, clock.now() + Duration::from_secs(1));
pin!(entry);
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_r... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/tests/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:4 | block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
});
thread::yield_now();
// advance 2s
handle.process_at_time(time_source.now() + 2_000_000_000);
jh.join().unwrap();
})
}
#[test]
fn reset_futu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/tests/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:5 | // shouldn't complete before 2s
block_on(futures::future::poll_fn(|cx| {
entry.as_mut().poll_elapsed(cx)
}))
.unwrap();
finished_early_.store(true, Ordering::Relaxed);
});
thread::yield_now();
// This may or may not return a wake... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/tests/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:6 | clock.now() + Duration::from_millis(i),
));
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(noop_waker_ref()));
entries.push(entry);
}
for t in 1..1024 {
handle.process_at_time(t as u64);
for (deadline, future) in entries.iter_mut... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/tests/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | use crate::park::Unpark;
use crate::time::driver::Inner;
use crate::time::Instant;
use loom::thread;
use std::sync::atomic::Ordering;
use std::sync::Arc;
struct MockUnpark;
impl Unpark for MockUnpark {
fn unpark(&self) {}
}
#[test]
fn balanced_incr_and_decr() {
const OPS: usize = 5;
fn incr(inner: Arc... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | f2005a78ca59f7e3bd1b59c99638e8a382a2b2fa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2005a78ca59f7e3bd1b59c99638e8a382a2b2fa/tokio/src/time/driver/tests/mod.rs | 1 | 55 |
tokio-rs/tokio:tokio/src/time/driver/tests/mod.rs:1 | use crate::park::Unpark;
use crate::time::driver::Inner;
use crate::time::Instant;
use loom::thread;
use std::sync::atomic::Ordering;
use std::sync::Arc;
struct MockUnpark;
impl Unpark for MockUnpark {
fn unpark(&self) {}
}
#[test]
fn balanced_incr_and_decr() {
const OPS: usize = 100;
fn incr(inner: A... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/time/driver/tests/mod.rs | MIT | 3fb213a8612699a46b2ccbeddd9adfbe3c468287 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fb213a8612699a46b2ccbeddd9adfbe3c468287/tokio/src/time/driver/tests/mod.rs | 1 | 55 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:1 | use crate::time::driver::TimerHandle;
use crate::time::driver::{EntryList, TimerShared};
use std::{fmt, ptr::NonNull};
/// Wheel for a single level in the timer. This wheel contains 64 slots.
pub(crate) struct Level {
level: usize,
/// Bit field tracking which slots currently contain entries.
///
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 28b983c4bc1f0041b59d590a55c6e4aafdf7b971 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28b983c4bc1f0041b59d590a55c6e4aafdf7b971/tokio/src/time/driver/wheel/level.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:2 | impl Level {
pub(crate) fn new(level: usize) -> Level {
// A value has to be Copy in order to use syntax like:
// let stack = Stack::default();
// ...
// slots: [stack; 64],
//
// Alternatively, since Stack is Default one can
// use syntax like:
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 28b983c4bc1f0041b59d590a55c6e4aafdf7b971 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28b983c4bc1f0041b59d590a55c6e4aafdf7b971/tokio/src/time/driver/wheel/level.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:3 | ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 28b983c4bc1f0041b59d590a55c6e4aafdf7b971 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28b983c4bc1f0041b59d590a55c6e4aafdf7b971/tokio/src/time/driver/wheel/level.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:4 | ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
],
}
}
/// Finds the slot that needs to be processed next and returns the slot and
/// `Instant` at which this slot must be processed.
pub(crate) fn next_expiration(&self, now: u6... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 28b983c4bc1f0041b59d590a55c6e4aafdf7b971 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28b983c4bc1f0041b59d590a55c6e4aafdf7b971/tokio/src/time/driver/wheel/level.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:5 | // that logically would go into the top+1 level, to instead go into
// the top level's slots.
//
// What this means is that the top level's slots act as a
// pseudo-ring buffer, and we rotate around them indefinitely. If we
// compute a deadline before now, an... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 28b983c4bc1f0041b59d590a55c6e4aafdf7b971 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28b983c4bc1f0041b59d590a55c6e4aafdf7b971/tokio/src/time/driver/wheel/level.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:6 | let slot = (zeros + now_slot) % 64;
Some(slot)
}
pub(crate) unsafe fn add_entry(&mut self, item: TimerHandle) {
let slot = slot_for(item.cached_when(), self.level);
self.slot[slot].push_front(item);
self.occupied |= occupied_bit(slot);
}
pub(crate) unsafe fn remove_e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 28b983c4bc1f0041b59d590a55c6e4aafdf7b971 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28b983c4bc1f0041b59d590a55c6e4aafdf7b971/tokio/src/time/driver/wheel/level.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:7 | fn occupied_bit(slot: usize) -> u64 {
1 << slot
}
fn slot_range(level: usize) -> u64 {
LEVEL_MULT.pow(level as u32) as u64
}
fn level_range(level: usize) -> u64 {
LEVEL_MULT as u64 * slot_range(level)
}
/// Converts a duration (milliseconds) and a level to a slot position.
fn slot_for(duration: u64, leve... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 28b983c4bc1f0041b59d590a55c6e4aafdf7b971 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28b983c4bc1f0041b59d590a55c6e4aafdf7b971/tokio/src/time/driver/wheel/level.rs | 241 | 276 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:4 | ctor(),
ctor(),
ctor(),
ctor(),
ctor(),
],
}
}
/// Finds the slot that needs to be processed next and returns the slot and
/// `Instant` at which this slot must be processed.
pub(crate) fn next_expiration(&self, now: u6... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | fe770dc509b19c5159ece7e38f353c5e30df3d6c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/time/driver/wheel/level.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:5 | // the top level's slots.
//
// What this means is that the top level's slots act as a
// pseudo-ring buffer, and we rotate around them indefinitely. If we
// compute a deadline before now, and it's the top level, it
// therefore means we're actually looking a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | fe770dc509b19c5159ece7e38f353c5e30df3d6c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/time/driver/wheel/level.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:1 | use crate::time::driver::TimerHandle;
use crate::time::driver::{EntryList, TimerShared};
use std::{fmt, ptr::NonNull};
/// Wheel for a single level in the timer. This wheel contains 64 slots.
pub(crate) struct Level {
level: usize,
/// Bit field tracking which slots currently contain entries.
///
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/level.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:2 | impl Level {
pub(crate) fn new(level: usize) -> Level {
// A value has to be Copy in order to use syntax like:
// let stack = Stack::default();
// ...
// slots: [stack; 64],
//
// Alternatively, since Stack is Default one can
// use syntax like:
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/level.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:6 | Some(slot)
}
pub(crate) unsafe fn add_entry(&mut self, item: TimerHandle) {
let slot = slot_for(item.cached_when(), self.level);
self.slot[slot].push_front(item);
self.occupied |= occupied_bit(slot);
}
pub(crate) unsafe fn remove_entry(&mut self, item: NonNull<TimerShared>) {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | c4f66ed121f2d7a05afb720d864fdc8f903aed0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c4f66ed121f2d7a05afb720d864fdc8f903aed0a/tokio/src/time/driver/wheel/level.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/wheel/level.rs:7 | fn occupied_bit(slot: usize) -> u64 {
1 << slot
}
fn slot_range(level: usize) -> u64 {
LEVEL_MULT.pow(level as u32) as u64
}
fn level_range(level: usize) -> u64 {
LEVEL_MULT as u64 * slot_range(level)
}
/// Convert a duration (milliseconds) and a level to a slot position
fn slot_for(duration: u64, level:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/level.rs | MIT | c4f66ed121f2d7a05afb720d864fdc8f903aed0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c4f66ed121f2d7a05afb720d864fdc8f903aed0a/tokio/src/time/driver/wheel/level.rs | 241 | 275 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:1 | use crate::time::driver::{TimerHandle, TimerShared};
use crate::time::error::InsertError;
mod level;
pub(crate) use self::level::Expiration;
use self::level::Level;
use std::ptr::NonNull;
use super::EntryList;
/// Timing wheel implementation.
///
/// This type provides the hashed timing wheel implementation that ba... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:4 | let when = item.as_ref().cached_when();
if when == u64::MAX {
self.pending.remove(item);
} else {
debug_assert!(
self.elapsed <= when,
"elapsed={}; when={}",
self.elapsed,
when
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:5 | Some(ref expiration) if expiration.deadline > now => return None,
Some(ref expiration) => {
self.process_expiration(expiration);
self.set_elapsed(expiration.deadline);
}
None => {
// in this case the poll did no... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:6 | }
None
}
/// Returns the tick at which this timer wheel next needs to perform some
/// processing, or None if there are no timers registered.
pub(super) fn next_expiration_time(&self) -> Option<u64> {
self.next_expiration().map(|ex| ex.deadline)
}
/// Used for debug assertions... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/mod.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:7 | // those entries again or we'll end up in an infinite loop.
let mut entries = self.take_entries(expiration);
while let Some(item) = entries.pop_back() {
if expiration.level == 0 {
debug_assert_eq!(unsafe { item.cached_when() }, expiration.deadline);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/mod.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:8 | fn take_entries(&mut self, expiration: &Expiration) -> EntryList {
self.levels[expiration.level].take_slot(expiration.slot)
}
fn level_for(&self, when: u64) -> usize {
level_for(self.elapsed, when)
}
}
fn level_for(elapsed: u64, when: u64) -> usize {
const SLOT_MASK: u64 = (1 << 6) - 1... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/mod.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:9 | );
}
for level in 1..5 {
for pos in level..64 {
let a = pos * 64_usize.pow(level as u32);
assert_eq!(
level,
level_for(0, a as u64),
"level_for({}) -- binary = {:b}",
a,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/mod.rs | 321 | 359 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:1 | use crate::time::driver::{TimerHandle, TimerShared};
use crate::time::error::InsertError;
mod level;
pub(crate) use self::level::Expiration;
use self::level::Level;
use std::ptr::NonNull;
use super::EntryList;
/// Timing wheel implementation.
///
/// This type provides the hashed timing wheel implementation that ba... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/time/driver/wheel/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:2 | pending: EntryList,
}
/// Number of levels. Each level has 64 slots. By using 6 levels with 64 slots
/// each, the timer is able to track time up to 2 years into the future with a
/// precision of 1 millisecond.
const NUM_LEVELS: usize = 6;
/// The maximum duration of a `Sleep`
pub(super) const MAX_DURATION: u64 = (1... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/time/driver/wheel/mod.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:3 | /// already passed. In this case, the caller should fire the timeout
/// immediately.
///
/// `Err(Invalid)` indicates an invalid `when` argument as been supplied.
///
/// # Safety
///
/// This function registers item into an intrusive linked list. The caller
/// must ensure that `item` ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/time/driver/wheel/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:4 | let when = item.as_ref().cached_when();
if when == u64::MAX {
self.pending.remove(item);
} else {
debug_assert!(
self.elapsed <= when,
"elapsed={}; when={}",
self.elapsed,
when
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/time/driver/wheel/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:3 | /// already passed. In this case, the caller should fire the timeout
/// immediately.
///
/// `Err(Invalid)` indicates an invalid `when` argument as been supplied.
///
/// # Safety
///
/// This function registers item into an intrusive linked list. The caller
/// must ensure that `item` ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | c4f66ed121f2d7a05afb720d864fdc8f903aed0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c4f66ed121f2d7a05afb720d864fdc8f903aed0a/tokio/src/time/driver/wheel/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:4 | let when = item.as_ref().cached_when();
if when == u64::max_value() {
self.pending.remove(item);
} else {
debug_assert!(
self.elapsed <= when,
"elapsed={}; when={}",
self.elapsed,
when... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | c4f66ed121f2d7a05afb720d864fdc8f903aed0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c4f66ed121f2d7a05afb720d864fdc8f903aed0a/tokio/src/time/driver/wheel/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:3 | /// already passed. In this case, the caller should fire the timeout
/// immediately.
///
/// `Err(Invalid)` indicates an invalid `when` argument as been supplied.
///
/// # Safety
///
/// This function registers item into an intrusive linked list. The caller
/// must ensure that `item` ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 9706ca92a8deb69d6e29265f21424042fea966c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9706ca92a8deb69d6e29265f21424042fea966c5/tokio/src/time/driver/wheel/mod.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:4 | let when = item.as_ref().cached_when();
if when == u64::max_value() {
self.pending.remove(item);
} else {
let level = self.level_for(when);
self.levels[level].remove_entry(item);
}
}
}
/// Instant at which to poll
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 9706ca92a8deb69d6e29265f21424042fea966c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9706ca92a8deb69d6e29265f21424042fea966c5/tokio/src/time/driver/wheel/mod.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:5 | // in this case the poll did not indicate an expiration
// _and_ we were not able to find a next expiration in
// the current list of timers. advance to the poll's
// current time and do nothing else.
self.set_elapsed(now);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 9706ca92a8deb69d6e29265f21424042fea966c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9706ca92a8deb69d6e29265f21424042fea966c5/tokio/src/time/driver/wheel/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:6 | pub(super) fn next_expiration_time(&self) -> Option<u64> {
self.next_expiration().map(|ex| ex.deadline)
}
/// Used for debug assertions
fn no_expirations_before(&self, start_level: usize, before: u64) -> bool {
let mut res = true;
for l2 in start_level..NUM_LEVELS {
if ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/mod.rs | MIT | 9706ca92a8deb69d6e29265f21424042fea966c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9706ca92a8deb69d6e29265f21424042fea966c5/tokio/src/time/driver/wheel/mod.rs | 201 | 260 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.