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/clock.rs:4 | start: std::time::Instant::now(),
frozen: Mutex::new(None),
}),
}
}
// TODO: delete this. Some tests rely on this
#[cfg(all(test, not(loom)))]
/// Return a new `Clock` instance that uses the current execution context's
/// source o... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 67bf9c36f347031ca05872d102a7f9abc8b465f0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/67bf9c36f347031ca05872d102a7f9abc8b465f0/tokio/src/time/clock.rs | 121 | 164 |
tokio-rs/tokio:tokio/src/time/clock.rs:1 | //! Source of time abstraction.
//!
//! By default, `std::time::Instant::now()` is used. However, when the
//! `test-util` feature flag is enabled, the values returned for `now()` are
//! configurable.
cfg_not_test_util! {
use crate::time::Instant;
#[derive(Debug, Clone)]
pub(crate) struct Clock {}
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/time/clock.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/clock.rs:2 | /// A handle to a source of time.
#[derive(Debug, Clone)]
pub(crate) struct Clock {
inner: Arc<Inner>,
}
#[derive(Debug)]
struct Inner {
/// Instant at which the clock was created
start: std::time::Instant,
/// Current, "frozen" time as an offset from `start`.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/time/clock.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/clock.rs:3 | if frozen.is_some() {
panic!("time is already frozen");
}
*frozen = Some(clock.inner.start.elapsed());
})
}
/// Resume time
///
/// Clears the saved `Instant::now()` value. Subsequent calls to
/// `Instant::now()` will return the value returned by th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/time/clock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/clock.rs:4 | /// # Panics
///
/// Panics if time is not frozen or if called from outside of the Tokio
/// runtime.
pub async fn advance(duration: Duration) {
CLOCK.with(|cell| {
let ptr = match cell.get() {
Some(ptr) => ptr,
None => panic!("time cannot be frozen fr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/time/clock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/clock.rs:5 | Clock {
inner: Arc::new(Inner {
start: std::time::Instant::now(),
frozen: Mutex::new(None),
}),
}
}
// TODO: delete this. Some tests rely on this
#[cfg(all(test, not(loom)))]
/// Return a new `Clock` ins... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/time/clock.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/clock.rs:6 | } else {
std::time::Instant::now()
})
}
/// Set the clock as the default source of time for the duration of the
/// closure
pub(crate) fn enter<F, R>(&self, f: F) -> R
where
F: FnOnce() -> R,
{
CLOCK.with(|cell| {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/time/clock.rs | 201 | 236 |
tokio-rs/tokio:tokio/src/time/clock.rs:1 | //! Source of time abstraction.
//!
//! By default, `std::time::Instant::now()` is used. However, when the
//! `test-util` feature flag is enabled, the values returned for `now()` are
//! configurable.
#[cfg(feature = "test-util")]
pub(crate) use self::variant::now;
pub(crate) use self::variant::Clock;
#[cfg(feature =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/clock.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/clock.rs:2 | }
#[cfg(feature = "test-util")]
mod variant {
use crate::time::{Duration, Instant};
use std::cell::Cell;
use std::sync::{Arc, Mutex};
/// A handle to a source of time.
#[derive(Debug, Clone)]
pub(crate) struct Clock {
inner: Arc<Inner>,
}
#[derive(Debug)]
struct Inner {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/clock.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/clock.rs:3 | CLOCK.with(|cell| {
let ptr = match cell.get() {
Some(ptr) => ptr,
None => panic!("time cannot be frozen from outside the Tokio runtime"),
};
let clock = unsafe { &*ptr };
let mut frozen = clock.inner.frozen.lock().unwrap();
i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/clock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/clock.rs:4 | *frozen = None;
})
}
/// Advance time
///
/// Increments the saved `Instant::now()` value by `duration`. Subsequent
/// calls to `Instant::now()` will return the result of the increment.
///
/// # Panics
///
/// Panics if time is not frozen or if called from outside of the T... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/clock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/clock.rs:5 | None => std::time::Instant::now(),
})
})
}
impl Clock {
/// Return a new `Clock` instance that uses the current execution context's
/// source of time.
pub(crate) fn new() -> Clock {
Clock {
inner: Arc::new(Inner {
star... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/clock.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/clock.rs:6 | // TODO: delete this as well
#[cfg(all(test, not(loom)))]
pub(crate) fn advanced(&self) -> Duration {
self.inner.frozen.lock().unwrap().unwrap()
}
pub(crate) fn now(&self) -> Instant {
Instant::from_std(if let Some(frozen) = *self.inner.frozen.lock().unwrap() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/clock.rs | 201 | 245 |
tokio-rs/tokio:tokio/src/time/clock.rs:1 | //! Source of time abstraction.
//!
//! By default, `std::time::Instant::now()` is used. However, when the
//! `test-util` feature flag is enabled, the values returned for `now()` are
//! configurable.
#[cfg(feature = "test-util")]
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/clock.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/clock.rs:2 | #[cfg(feature = "test-util")]
mod variant {
use crate::time::{Duration, Instant};
use std::cell::Cell;
use std::sync::{Arc, Mutex};
/// A handle to a source of time.
#[derive(Debug, Clone)]
pub(crate) struct Clock {
inner: Arc<Inner>,
}
#[derive(Debug)]
struct Inner {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/clock.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/clock.rs:3 | Some(ptr) => ptr,
None => panic!("time cannot be frozen from outside the Tokio runtime"),
};
let clock = unsafe { &*ptr };
let mut frozen = clock.inner.frozen.lock().unwrap();
if frozen.is_some() {
panic!("time is already frozen");
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/clock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/clock.rs:4 | }
/// Advance time
///
/// Increments the saved `Instant::now()` value by `duration`. Subsequent
/// calls to `Instant::now()` will return the result of the increment.
///
/// # Panics
///
/// Panics if time is not frozen or if called from outside of the Tokio
/// runtime.
pub a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/clock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/clock.rs:5 | })
}
impl Clock {
/// Return a new `Clock` instance that uses the current execution context's
/// source of time.
pub(crate) fn new() -> Clock {
Clock {
inner: Arc::new(Inner {
start: std::time::Instant::now(),
frozen: ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/clock.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/clock.rs:6 | pub(crate) fn advanced(&self) -> Duration {
self.inner.frozen.lock().unwrap().unwrap()
}
pub(crate) fn now(&self) -> Instant {
Instant::from_std(if let Some(frozen) = *self.inner.frozen.lock().unwrap() {
self.inner.start + frozen
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/clock.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/clock.rs | 201 | 243 |
tokio-rs/tokio:tokio/src/time/delay.rs:2 | /// 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 sleep(duration: Du... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | fcdf9345bf19e9a1e1664f01713f9eba54da27c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcdf9345bf19e9a1e1664f01713f9eba54da27c5/tokio/src/time/delay.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/delay.rs:3 | /// Returns `true` if the `Delay` has elapsed
///
/// A `Delay` is elapsed when the requested duration has elapsed.
pub fn is_elapsed(&self) -> bool {
self.entry.is_elapsed()
}
/// Resets the `Delay` instance to a new deadline.
///
/// Calling this function allows changing the insta... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | fcdf9345bf19e9a1e1664f01713f9eba54da27c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcdf9345bf19e9a1e1664f01713f9eba54da27c5/tokio/src/time/delay.rs | 81 | 139 |
tokio-rs/tokio:tokio/src/time/delay.rs:4 | // - AtCapacity: this is a pathological case where far too many
// delays 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 panic in this case.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | fcdf9345bf19e9a1e1664f01713f9eba54da27c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcdf9345bf19e9a1e1664f01713f9eba54da27c5/tokio/src/time/delay.rs | 121 | 139 |
tokio-rs/tokio:tokio/src/time/delay.rs:2 | /// 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 sleep(duration: Du... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/delay.rs:3 | ///
/// A `Delay` is elapsed when the requested duration has elapsed.
pub fn is_elapsed(&self) -> bool {
self.registration.is_elapsed()
}
/// Resets the `Delay` instance to a new deadline.
///
/// Calling this function allows changing the instant at which the `Delay`
/// future comp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay.rs | 81 | 117 |
tokio-rs/tokio:tokio/src/time/delay.rs:2 | /// Wait 100ms and print "100 ms have elapsed".
///
/// ```
/// use tokio::time::{delay_for, Duration};
///
/// #[tokio::main]
/// async fn main() {
/// delay_for(Duration::from_millis(100)).await;
/// println!("100 ms have elapsed");
/// }
/// ```
///
/// [`interval`]: crate::time::interval()
#[cfg_attr(docsrs... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | e2adf2612d215d1925ef0dd9e2aa8cdd4c825abc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2adf2612d215d1925ef0dd9e2aa8cdd4c825abc/tokio/src/time/delay.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/delay.rs:3 | /// Returns `true` if the `Delay` has elapsed
///
/// A `Delay` is elapsed when the requested duration has elapsed.
pub fn is_elapsed(&self) -> bool {
self.registration.is_elapsed()
}
/// Resets the `Delay` instance to a new deadline.
///
/// Calling this function allows changing th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | e2adf2612d215d1925ef0dd9e2aa8cdd4c825abc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2adf2612d215d1925ef0dd9e2aa8cdd4c825abc/tokio/src/time/delay.rs | 81 | 118 |
tokio-rs/tokio:tokio/src/time/delay.rs:1 | use crate::time::driver::Registration;
use crate::time::{Duration, Instant};
use std::future::Future;
use std::pin::Pin;
use std::task::{self, Poll};
/// Waits until `deadline` is reached.
///
/// No work is performed while awaiting on the delay to complete. The delay
/// operates at millisecond granularity and shoul... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 0a422593f0196840a176895cb3394c3c3314fdb2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0a422593f0196840a176895cb3394c3c3314fdb2/tokio/src/time/delay.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/delay.rs:2 | /// Future returned by [`delay_until`](delay_until) and
/// [`delay_for`](delay_for).
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Delay {
/// The link between the `Delay` instance and the timer that drives it.
///
/// This also stores the `deadline` value.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 0a422593f0196840a176895cb3394c3c3314fdb2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0a422593f0196840a176895cb3394c3c3314fdb2/tokio/src/time/delay.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/delay.rs:3 | impl Future for Delay {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// `poll_elapsed` can return an error in two cases:
//
// - AtCapacity: this is a pathlogical case where far too many
// delays have been scheduled.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 0a422593f0196840a176895cb3394c3c3314fdb2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0a422593f0196840a176895cb3394c3c3314fdb2/tokio/src/time/delay.rs | 81 | 100 |
tokio-rs/tokio:tokio/src/time/delay.rs:1 | use crate::time::driver::Registration;
use crate::time::{Duration, Instant};
use std::future::Future;
use std::pin::Pin;
use std::task::{self, Poll};
/// Waits until `deadline` is reached.
///
/// No work is performed while awaiting on the delay to complete. The delay
/// operates at millisecond granularity and shoul... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/delay.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/delay.rs:2 | /// [`delay_for`](delay_for).
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Delay {
/// The link between the `Delay` instance and the timer that drives it.
///
/// This also stores the `deadline` value.
registration: Registration,
}
impl Delay {
pub... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/delay.rs | 41 | 99 |
tokio-rs/tokio:tokio/src/time/delay.rs:1 | use crate::time::driver::Registration;
use crate::time::{Duration, Instant};
use std::future::Future;
use std::pin::Pin;
use std::task::{self, Poll};
/// Wait until `deadline` is reached.
///
/// No work is performed while awaiting on the delay to complete. The delay
/// operates at millisecond granularity and should... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 3e643c7b81736a4c2b11387a6f71aba99450270b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/delay.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/delay.rs:2 | /// [`delay_for`](delay_for).
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Delay {
/// The link between the `Delay` instance and the timer that drives it.
///
/// This also stores the `deadline` value.
registration: Registration,
}
impl Delay {
pub... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 3e643c7b81736a4c2b11387a6f71aba99450270b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/delay.rs | 41 | 99 |
tokio-rs/tokio:tokio/src/time/delay.rs:1 | use crate::time::driver::Registration;
use crate::time::{Duration, Instant};
use std::future::Future;
use std::pin::Pin;
use std::task::{self, Poll};
/// Wait until `deadline` is reached.
///
/// No work is performed while awaiting on the delay to complete. The delay
/// operates at millisecond granularity and should... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/delay.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/delay.rs:2 | /// [`delay_for`](delay_for).
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Delay {
/// The link between the `Delay` instance at the timer that drives it.
///
/// This also stores the `deadline` value.
registration: Registration,
}
impl Delay {
pub(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/delay.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/delay.rs:3 | /// context.
fn register(&mut self) {
self.registration.register();
}
}
impl Future for Delay {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// Ensure the `Delay` instance is associated with a timer.
self.register();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/time/delay.rs | 81 | 108 |
tokio-rs/tokio:tokio/src/time/delay.rs:1 | use crate::time::driver::Registration;
use crate::time::{Duration, Instant};
use futures_core::ready;
use std::future::Future;
use std::pin::Pin;
use std::task::{self, Poll};
/// A future that completes at a specified instant in time.
///
/// Instances of `Delay` perform no work and complete with `()` once the
/// sp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/delay.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/delay.rs:2 | Delay { registration }
}
pub(crate) fn new_timeout(deadline: Instant, duration: Duration) -> Delay {
let registration = Registration::new(deadline, duration);
Delay { registration }
}
/// Returns the instant at which the future will complete.
pub fn deadline(&self) -> Instant {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/delay.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/delay.rs:3 | }
impl Future for Delay {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// Ensure the `Delay` instance is associated with a timer.
self.register();
// `poll_elapsed` can return an error in two cases:
//
// - AtC... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/delay.rs | 81 | 104 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:4 | /// [`sleep`]: fn@super::sleep
/// [`slab`]: slab
/// [`capacity`]: method@Self::capacity
/// [`reserve`]: method@Self::reserve
#[derive(Debug)]
pub struct DelayQueue<T> {
/// Stores data associated with entries
slab: Slab<Data<T>>,
/// Lookup structure tracking all delays in the queue
wheel: Wheel<Sta... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:5 | key: Key,
}
/// Token to a value stored in a `DelayQueue`.
///
/// Instances of `Key` are returned by [`DelayQueue::insert`]. See [`DelayQueue`]
/// documentation for more details.
///
/// [`DelayQueue`]: struct@DelayQueue
/// [`DelayQueue::insert`]: method@DelayQueue::insert
#[derive(Debug, Clone)]
pub struct Key {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:6 | /// Maximum number of entries the queue can handle
const MAX_ENTRIES: usize = (1 << 30) - 1;
impl<T> DelayQueue<T> {
/// Creates a new, empty, `DelayQueue`
///
/// The queue will not allocate storage until items are inserted into it.
///
/// # Examples
///
/// ```rust
/// # use tokio::t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:8 | /// Basic usage
///
/// ```rust
/// use tokio::time::{DelayQueue, Duration, Instant};
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// let key = delay_queue.insert_at(
/// "foo", Instant::now() + Duration::from_secs(5))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:9 | let should_set_delay = if let Some(ref delay) = self.delay {
let current_exp = self.normalize_deadline(delay.deadline());
current_exp > when
} else {
true
};
if should_set_delay {
let delay_time = self.start + Duration::from_millis(when);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:11 | ///
/// // Remove the entry
/// let item = delay_queue.remove(&key);
/// assert_eq!(*item.get_ref(), "foo");
/// # }
/// ```
///
/// [`poll_expired`]: method@Self::poll_expired
/// [`remove`]: method@Self::remove
/// [`reset`]: method@Self::reset
/// [`Key`]: struct@K... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:12 | if self.slab[key.index].expired {
self.expired.remove(&key.index, &mut self.slab);
} else {
self.wheel.remove(&key.index, &mut self.slab);
}
}
/// Removes the item associated with `key` from the queue.
///
/// There must be an item associated with `key`. The func... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:13 | key: Key::new(key.index),
data: data.inner,
deadline: self.start + Duration::from_millis(data.when),
}
}
/// Sets the delay of the item associated with `key` to expire at `when`.
///
/// This function is identical to `reset` but takes an `Instant` instead of
/// a `D... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:14 | self.remove_key(key);
// Normalize the deadline. Values cannot be set to expire in the past.
let when = self.normalize_deadline(when);
self.slab[key.index].when = when;
self.insert_idx(when, key.index);
let next_deadline = self.next_deadline();
if let (Some(ref mut del... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:18 | /// ```
pub fn reserve(&mut self, additional: usize) {
self.slab.reserve(additional);
}
/// Returns `true` if there are no items in the queue.
///
/// Note that this function returns `false` even if all items have not yet
/// expired and a call to `poll` will return `NotReady`.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:19 | }
loop {
if let Some(ref mut delay) = self.delay {
if !delay.is_elapsed() {
ready!(Pin::new(&mut *delay).poll(cx));
}
let now = crate::time::ms(delay.deadline() - self.start, crate::time::Round::Down);
self.poll =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:20 | impl<T> Unpin for DelayQueue<T> {}
impl<T> Default for DelayQueue<T> {
fn default() -> DelayQueue<T> {
DelayQueue::new()
}
}
#[cfg(feature = "stream")]
impl<T> futures_core::Stream for DelayQueue<T> {
// DelayQueue seems much more specific, where a user may care that it
// has reached capacity... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:21 | store[item].next = old;
self.head = Some(item)
}
fn pop(&mut self, store: &mut Self::Store) -> Option<Self::Owned> {
if let Some(idx) = self.head {
self.head = store[idx].next;
if let Some(idx) = self.head {
store[idx].prev = None;
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:22 | });
if let Some(next) = store[*item].next {
store[next].prev = store[*item].prev;
}
if let Some(prev) = store[*item].prev {
store[prev].next = store[*item].next;
} else {
self.head = store[*item].next;
}
store[*item].next = None;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 841 | 897 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:23 | }
/// Returns a mutable reference to the inner value.
pub fn get_mut(&mut self) -> &mut T {
&mut self.data
}
/// Consumes `self` and returns the inner value.
pub fn into_inner(self) -> T {
self.data
}
/// Returns the deadline that the expiration was set to.
pub fn dead... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/delay_queue.rs | 881 | 897 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:4 | /// [`delay_for`]: fn@super::delay_for
/// [`slab`]: slab
/// [`capacity`]: method@Self::capacity
/// [`reserve`]: method@Self::reserve
#[derive(Debug)]
pub struct DelayQueue<T> {
/// Stores data associated with entries
slab: Slab<Data<T>>,
/// Lookup structure tracking all delays in the queue
wheel: W... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769/tokio/src/time/delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:8 | /// Basic usage
///
/// ```rust
/// use tokio::time::{DelayQueue, Duration, Instant};
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// let key = delay_queue.insert_at(
/// "foo", Instant::now() + Duration::from_secs(5))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769/tokio/src/time/delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:9 | let should_set_delay = if let Some(ref delay) = self.delay {
let current_exp = self.normalize_deadline(delay.deadline());
current_exp > when
} else {
true
};
if should_set_delay {
let delay_time = self.start + Duration::from_millis(when);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769/tokio/src/time/delay_queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:18 | /// ```
pub fn reserve(&mut self, additional: usize) {
self.slab.reserve(additional);
}
/// Returns `true` if there are no items in the queue.
///
/// Note that this function returns `false` even if all items have not yet
/// expired and a call to `poll` will return `NotReady`.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769/tokio/src/time/delay_queue.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:19 | }
loop {
if let Some(ref mut delay) = self.delay {
if !delay.is_elapsed() {
ready!(Pin::new(&mut *delay).poll(cx));
}
let now = crate::time::ms(delay.deadline() - self.start, crate::time::Round::Down);
self.poll =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce0af8f7a188c9b8b8b4dcc3847674fd0afbe769/tokio/src/time/delay_queue.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:9 | let should_set_delay = if let Some(ref delay) = self.delay {
let current_exp = self.normalize_deadline(delay.deadline());
current_exp > when
} else {
true
};
if should_set_delay {
let delay_time = self.start + Duration::from_millis(when);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:11 | /// let item = delay_queue.remove(&key);
/// assert_eq!(*item.get_ref(), "foo");
/// # }
/// ```
///
/// [`poll_expired`]: method@Self::poll_expired
/// [`remove`]: method@Self::remove
/// [`reset`]: method@Self::reset
/// [`Key`]: struct@Key
/// [type]: #
pub fn insert(&... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:13 | deadline: self.start + Duration::from_millis(data.when),
}
}
/// Sets the delay of the item associated with `key` to expire at `when`.
///
/// This function is identical to `reset` but takes an `Instant` instead of
/// a `Duration`.
///
/// The item remains in the queue but the dela... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:14 | // Normalize the deadline. Values cannot be set to expire in the past.
let when = self.normalize_deadline(when);
self.slab[key.index].when = when;
self.insert_idx(when, key.index);
let next_deadline = self.next_deadline();
if let (Some(ref mut delay), Some(deadline)) = (&mut se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:18 | self.slab.reserve(additional);
}
/// Returns `true` if there are no items in the queue.
///
/// Note that this function returns `false` even if all items have not yet
/// expired and a call to `poll` will return `NotReady`.
///
/// # Examples
///
/// ```
/// use tokio::time::Del... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:19 | loop {
if let Some(ref mut delay) = self.delay {
if !delay.is_elapsed() {
ready!(Pin::new(&mut *delay).poll(cx));
}
let now = crate::time::ms(delay.deadline() - self.start, crate::time::Round::Down);
self.poll = wheel::Pol... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:20 | impl<T> Default for DelayQueue<T> {
fn default() -> DelayQueue<T> {
DelayQueue::new()
}
}
#[cfg(feature = "stream")]
impl<T> futures_core::Stream for DelayQueue<T> {
// DelayQueue seems much more specific, where a user may care that it
// has reached capacity, so return those errors instead of ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:22 | if let Some(next) = store[*item].next {
store[next].prev = store[*item].prev;
}
if let Some(prev) = store[*item].prev {
store[prev].next = store[*item].next;
} else {
self.head = store[*item].next;
}
store[*item].next = None;
store[*i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 841 | 895 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:23 | /// Returns a mutable reference to the inner value.
pub fn get_mut(&mut self) -> &mut T {
&mut self.data
}
/// Consumes `self` and returns the inner value.
pub fn into_inner(self) -> T {
self.data
}
/// Returns the deadline that the expiration was set to.
pub fn deadline(&s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 262b19ae965c663a39bf5ff07b6ae5ec619e911d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/262b19ae965c663a39bf5ff07b6ae5ec619e911d/tokio/src/time/delay_queue.rs | 881 | 895 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:4 | /// [`delay_for`]: fn@super::delay_for
/// [`slab`]: slab
/// [`capacity`]: method@Self::capacity
/// [`reserve`]: method@Self::reserve
#[derive(Debug)]
pub struct DelayQueue<T> {
/// Stores data associated with entries
slab: Slab<Data<T>>,
/// Lookup structure tracking all delays in the queue
wheel: W... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/src/time/delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:8 | /// Basic usage
///
/// ```rust
/// use tokio::time::{DelayQueue, Duration, Instant};
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// let key = delay_queue.insert_at(
/// "foo", Instant::now() + Duration::from_secs(5))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/src/time/delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:9 | let should_set_delay = if let Some(ref delay) = self.delay {
let current_exp = self.normalize_deadline(delay.deadline());
current_exp > when
} else {
true
};
if should_set_delay {
let delay_time = self.start + Duration::from_millis(when);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/src/time/delay_queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:11 | /// let item = delay_queue.remove(&key);
/// assert_eq!(*item.get_ref(), "foo");
/// # }
/// ```
///
/// [`poll`]: method@Self::poll
/// [`remove`]: method@Self::remove
/// [`reset`]: method@Self::reset
/// [`Key`]: struct@Key
/// [type]: #
pub fn insert(&mut self, value:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/src/time/delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:11 | /// let item = delay_queue.remove(&key);
/// assert_eq!(*item.get_ref(), "foo");
/// # }
/// ```
///
/// [`poll`]: method@Self::poll
/// [`remove`]: method@Self::remove
/// [`reset`]: method@Self::reset
/// [`Key`]: struct@Key
/// [type]: #
pub fn insert(&mut self, value:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/time/delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:12 | ///
/// Basic usage
///
/// ```rust
/// use tokio::time::DelayQueue;
/// use std::time::Duration;
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// let key = delay_queue.insert("foo", Duration::from_secs(5));
///
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/time/delay_queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:13 | ///
/// The item remains in the queue but the delay is set to expire at `when`.
/// If `when` is in the past, then the item is immediately made available to
/// the caller.
///
/// # Panics
///
/// This function panics if `when` is too far in the future or if `key` is
/// not contained b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/time/delay_queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:18 | /// # Examples
///
/// ```
/// use tokio::time::DelayQueue;
/// use std::time::Duration;
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// assert!(delay_queue.is_empty());
///
/// delay_queue.insert("hello", Duration... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/time/delay_queue.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:19 | self.poll = wheel::Poll::new(now);
}
// We poll the wheel to get the next value out before finding the next deadline.
let wheel_idx = self.wheel.poll(&mut self.poll, &mut self.slab);
self.delay = self.next_deadline().map(delay_until);
if let Some(idx) = whe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/time/delay_queue.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:20 | // DelayQueue seems much more specific, where a user may care that it
// has reached capacity, so return those errors instead of panicking.
type Item = Result<Expired<T>, Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Option<Self::Item>> {
DelayQueue::poll_expired(se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/time/delay_queue.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:21 | }
store[idx].next = None;
debug_assert!(store[idx].prev.is_none());
Some(idx)
} else {
None
}
}
fn remove(&mut self, item: &Self::Borrowed, store: &mut Self::Store) {
assert!(store.contains(*item));
// Ensure that the entry is i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/time/delay_queue.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:22 | }
store[*item].next = None;
store[*item].prev = None;
}
fn when(item: &Self::Borrowed, store: &Self::Store) -> u64 {
store[*item].when
}
}
impl<T> Default for Stack<T> {
fn default() -> Stack<T> {
Stack {
head: None,
_p: PhantomData,
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/time/delay_queue.rs | 841 | 887 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:4 | /// [`delay_for`]: fn@super::delay_for
/// [`slab`]: https://docs.rs/slab
/// [`capacity`]: method@Self::capacity
/// [`reserve`]: method@Self::reserve
#[derive(Debug)]
pub struct DelayQueue<T> {
/// Stores data associated with entries
slab: Slab<Data<T>>,
/// Lookup structure tracking all delays in the qu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | f2f30d4cf6dfad9ed5b1e393b91bc2ed4e244483 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2f30d4cf6dfad9ed5b1e393b91bc2ed4e244483/tokio/src/time/delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:4 | /// [`delay_for`]: fn@super::delay_for
/// [`slab`]: https://docs.rs/slab
/// [`capacity`]: #method.capacity
/// [`reserve`]: #method.reserve
#[derive(Debug)]
pub struct DelayQueue<T> {
/// Stores data associated with entries
slab: Slab<Data<T>>,
/// Lookup structure tracking all delays in the queue
wh... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 9553355c2709235686030bb1a299dc83a053347c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9553355c2709235686030bb1a299dc83a053347c/tokio/src/time/delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:8 | /// Basic usage
///
/// ```rust
/// use tokio::time::{DelayQueue, Duration, Instant};
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// let key = delay_queue.insert_at(
/// "foo", Instant::now() + Duration::from_secs(5))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 9553355c2709235686030bb1a299dc83a053347c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9553355c2709235686030bb1a299dc83a053347c/tokio/src/time/delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:11 | /// let item = delay_queue.remove(&key);
/// assert_eq!(*item.get_ref(), "foo");
/// # }
/// ```
///
/// [`poll`]: #method.poll
/// [`remove`]: #method.remove
/// [`reset`]: #method.reset
/// [`Key`]: struct@Key
/// [type]: #
pub fn insert(&mut self, value: T, timeout: Du... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 9553355c2709235686030bb1a299dc83a053347c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9553355c2709235686030bb1a299dc83a053347c/tokio/src/time/delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:4 | /// [`Timer`]: ../struct.Timer.html
/// [`slab`]: https://docs.rs/slab
/// [`capacity`]: #method.capacity
/// [`reserve`]: #method.reserve
#[derive(Debug)]
pub struct DelayQueue<T> {
/// Stores data associated with entries
slab: Slab<Data<T>>,
/// Lookup structure tracking all delays in the queue
wheel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | f39c15334e74b07a44efaa0f7201262e17e4f062 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/time/delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:4 | /// [`Timer`]: ../struct.Timer.html
/// [`slab`]: https://docs.rs/slab
/// [`capacity`]: #method.capacity
/// [`reserve`]: #method.reserve
#[derive(Debug)]
pub struct DelayQueue<T> {
/// Stores data associated with entries
slab: Slab<Data<T>>,
/// Lookup structure tracking all delays in the queue
wheel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 03cb3b6ca12627041f153e018ef099dda921d11a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03cb3b6ca12627041f153e018ef099dda921d11a/tokio/src/time/delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:5 | key: Key,
}
/// Token to a value stored in a `DelayQueue`.
///
/// Instances of `Key` are returned by [`DelayQueue::insert`]. See [`DelayQueue`]
/// documentation for more details.
///
/// [`DelayQueue`]: struct.DelayQueue.html
/// [`DelayQueue::insert`]: struct.DelayQueue.html#method.insert
#[derive(Debug, Clone)]
pu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 03cb3b6ca12627041f153e018ef099dda921d11a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03cb3b6ca12627041f153e018ef099dda921d11a/tokio/src/time/delay_queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:8 | /// Basic usage
///
/// ```rust
/// use tokio::time::{DelayQueue, Duration, Instant};
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// let key = delay_queue.insert_at(
/// "foo", Instant::now() + Duration::from_secs(5))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 03cb3b6ca12627041f153e018ef099dda921d11a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03cb3b6ca12627041f153e018ef099dda921d11a/tokio/src/time/delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:11 | /// let item = delay_queue.remove(&key);
/// assert_eq!(*item.get_ref(), "foo");
/// # }
/// ```
///
/// [`poll`]: #method.poll
/// [`remove`]: #method.remove
/// [`reset`]: #method.reset
/// [`Key`]: struct.Key.html
/// [type]: #
pub fn insert(&mut self, value: T, timeou... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 03cb3b6ca12627041f153e018ef099dda921d11a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03cb3b6ca12627041f153e018ef099dda921d11a/tokio/src/time/delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:22 | }
store[*item].next = None;
store[*item].prev = None;
}
fn when(item: &Self::Borrowed, store: &Self::Store) -> u64 {
store[*item].when
}
}
impl<T> Default for Stack<T> {
fn default() -> Stack<T> {
Stack {
head: None,
_p: PhantomData,
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 6cf1a5b6b8686e5bde107d072d77199aaefcb2ec | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6cf1a5b6b8686e5bde107d072d77199aaefcb2ec/tokio/src/time/delay_queue.rs | 841 | 882 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:18 | /// # Examples
///
/// ```
/// use tokio::time::DelayQueue;
/// use std::time::Duration;
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// assert!(delay_queue.is_empty());
///
/// delay_queue.insert("hello", Duration... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7207bf355e2b6418bb0d757859a5cdcdedf32530 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207bf355e2b6418bb0d757859a5cdcdedf32530/tokio/src/time/delay_queue.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:19 | self.poll = wheel::Poll::new(now);
}
self.delay = None;
if let Some(idx) = self.wheel.poll(&mut self.poll, &mut self.slab) {
return Poll::Ready(Some(Ok(idx)));
}
if let Some(deadline) = self.next_deadline() {
self.delay = Som... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7207bf355e2b6418bb0d757859a5cdcdedf32530 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207bf355e2b6418bb0d757859a5cdcdedf32530/tokio/src/time/delay_queue.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:20 | // has reached capacity, so return those errors instead of panicking.
type Item = Result<Expired<T>, Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Option<Self::Item>> {
DelayQueue::poll_expired(self.get_mut(), cx)
}
}
impl<T> wheel::Stack for Stack<T> {
type Ow... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7207bf355e2b6418bb0d757859a5cdcdedf32530 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207bf355e2b6418bb0d757859a5cdcdedf32530/tokio/src/time/delay_queue.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:21 | store[idx].next = None;
debug_assert!(store[idx].prev.is_none());
Some(idx)
} else {
None
}
}
fn remove(&mut self, item: &Self::Borrowed, store: &mut Self::Store) {
assert!(store.contains(*item));
// Ensure that the entry is in fact containe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7207bf355e2b6418bb0d757859a5cdcdedf32530 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207bf355e2b6418bb0d757859a5cdcdedf32530/tokio/src/time/delay_queue.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:22 | store[*item].next = None;
store[*item].prev = None;
}
fn when(item: &Self::Borrowed, store: &Self::Store) -> u64 {
store[*item].when
}
}
impl<T> Default for Stack<T> {
fn default() -> Stack<T> {
Stack {
head: None,
_p: PhantomData,
}
}
}
imp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | 7207bf355e2b6418bb0d757859a5cdcdedf32530 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207bf355e2b6418bb0d757859a5cdcdedf32530/tokio/src/time/delay_queue.rs | 841 | 881 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:8 | /// Basic usage
///
/// ```rust
/// use tokio::time::{DelayQueue, Duration, Instant};
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// let key = delay_queue.insert_at(
/// "foo", Instant::now() + Duration::from_secs(5))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:9 | let should_set_delay = if let Some(ref delay) = self.delay {
let current_exp = self.normalize_deadline(delay.deadline());
current_exp > when
} else {
true
};
if should_set_delay {
self.delay = Some(delay_until(self.start + Duration::from_millis(wh... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/delay_queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:11 | /// [`poll`]: #method.poll
/// [`remove`]: #method.remove
/// [`reset`]: #method.reset
/// [`Key`]: struct.Key.html
/// [type]: #
pub fn insert(&mut self, value: T, timeout: Duration) -> Key {
self.insert_at(value, Instant::now() + timeout)
}
fn insert_idx(&mut self, when: u64, key:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:12 | /// use std::time::Duration;
///
/// # #[tokio::main]
/// # async fn main() {
/// let mut delay_queue = DelayQueue::new();
/// let key = delay_queue.insert("foo", Duration::from_secs(5));
///
/// // Remove the entry
/// let item = delay_queue.remove(&key);
/// ass... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/delay_queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/time/delay_queue.rs:13 | /// # Panics
///
/// This function panics if `when` is too far in the future or if `key` is
/// not contained by the queue.
///
/// # Examples
///
/// Basic usage
///
/// ```rust
/// use tokio::time::{DelayQueue, Duration, Instant};
///
/// # #[tokio::main]
/// # asyn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/delay_queue.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/delay_queue.rs | 481 | 540 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.