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/wheel/mod.rs:7 | // Try to expire the entry; this is cheap (doesn't synchronize) if
// the timer is not expired, and updates cached_when.
match unsafe { item.mark_pending(expiration.deadline) } {
Ok(()) => {
// Item was expired
self.pending.push_front(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 | 241 | 300 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:8 | }
fn level_for(elapsed: u64, when: u64) -> usize {
let mut masked = elapsed ^ when;
if masked >= MAX_DURATION {
// Fudge the timer into the top level
masked = MAX_DURATION - 1;
}
assert!(masked != 0, "elapsed={}; when={}", elapsed, when);
let leading_zeros = masked.leading_zeros(... | 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 | 281 | 340 |
tokio-rs/tokio:tokio/src/time/driver/wheel/mod.rs:9 | "level_for({}) -- binary = {:b}",
a,
a
);
if pos > level {
let a = a - 1;
assert_eq!(
level,
level_for(0, a as u64),
"level_for({}) -- ... | 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 | 321 | 350 |
tokio-rs/tokio:tokio/src/time/driver/wheel/stack.rs:1 | use super::{Item, OwnedItem};
use crate::time::driver::Entry;
use std::ptr;
/// A doubly linked stack.
#[derive(Debug)]
pub(crate) struct Stack {
head: Option<OwnedItem>,
}
impl Default for Stack {
fn default() -> Stack {
Stack { head: None }
}
}
impl Stack {
pub(crate) fn is_empty(&self) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/stack.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/stack.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/driver/wheel/stack.rs:2 | // Set the previous link on the old head
*entry.prev_stack.get() = ptr;
}
// Set this entry's next pointer
*entry.next_stack.get() = old;
}
// Update the head pointer
self.head = Some(entry);
}
/// Pops an item from the stack.
pu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/stack.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/stack.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/driver/wheel/stack.rs:3 | if entry as *const _ == &**n as *const _ {
debug_assert!(!contains);
contains = true;
}
next = (*n.next_stack.get()).as_ref();
}
contains
});
// Unlink `entry` from the next... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/driver/wheel/stack.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/wheel/stack.rs | 81 | 112 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | //! Time error types.
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the operation will nev... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | /// Errors returned by `Timeout`.
///
/// This error is returned when a timeout expires before the function was able
/// to finish.
#[derive(Debug, PartialEq, Eq)]
pub struct Elapsed(());
#[derive(Debug)]
pub(crate) enum InsertError {
Elapsed,
}
// ===== impl Error =====
impl Error {
/// Creates an error rep... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:3 | /// Returns `true` if the error was caused by the timer being misconfigured.
pub fn is_invalid(&self) -> bool {
matches!(self.0, Kind::Invalid)
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let descr = match se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/error.rs | 81 | 123 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | /// Errors returned by `Timeout`.
///
/// This error is returned when a timeout expires before the function was able
/// to finish.
#[derive(Debug, PartialEq, Eq)]
pub struct Elapsed(());
#[derive(Debug)]
pub(crate) enum InsertError {
Elapsed,
}
// ===== impl Error =====
impl Error {
/// Creates an error rep... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:3 | /// Returns `true` if the error was caused by the timer being misconfigured.
pub fn is_invalid(&self) -> bool {
matches!(self.0, Kind::Invalid)
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let descr = match se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/time/error.rs | 81 | 123 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | //! Time error types.
use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | }
/// Errors returned by `Timeout`.
///
/// This error is returned when a timeout expires before the function was able
/// to finish.
#[derive(Debug, PartialEq, Eq)]
pub struct Elapsed(());
#[derive(Debug)]
pub(crate) enum InsertError {
Elapsed,
}
// ===== impl Error =====
impl Error {
/// Creates an error ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:3 | }
/// Returns `true` if the error was caused by the timer being misconfigured.
pub fn is_invalid(&self) -> bool {
matches!(self.0, Kind::Invalid)
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::Kin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/src/time/error.rs | 81 | 123 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | //! Time error types.
use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | d32ba2cf9d9b7eac3a904f558e5fe4397cc83e89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d32ba2cf9d9b7eac3a904f558e5fe4397cc83e89/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | }
/// Errors returned by `Timeout`.
///
/// This error is returned when a timeout expires before the function was able
/// to finish.
#[derive(Debug, PartialEq)]
pub struct Elapsed(());
#[derive(Debug)]
pub(crate) enum InsertError {
Elapsed,
}
// ===== impl Error =====
impl Error {
/// Creates an error repr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | d32ba2cf9d9b7eac3a904f558e5fe4397cc83e89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d32ba2cf9d9b7eac3a904f558e5fe4397cc83e89/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | //! Time error types.
use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | }
/// Errors returned by `Timeout`.
#[derive(Debug, PartialEq)]
pub struct Elapsed(());
#[derive(Debug)]
pub(crate) enum InsertError {
Elapsed,
}
// ===== impl Error =====
impl Error {
/// Creates an error representing a shutdown timer.
pub fn shutdown() -> Error {
Error(Shutdown)
}
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:3 | pub fn is_invalid(&self) -> bool {
matches!(self.0, Kind::Invalid)
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::Kind::*;
let descr = match self.0 {
Shutdown => "the timer is shutdown,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/error.rs | 81 | 120 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | //! Time error types.
use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | ce0e9c67cfe61c7a91a284331ecc53fa01c32879 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce0e9c67cfe61c7a91a284331ecc53fa01c32879/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | }
/// Error returned by `Timeout`.
#[derive(Debug, PartialEq)]
pub struct Elapsed(());
#[derive(Debug)]
pub(crate) enum InsertError {
Elapsed,
}
// ===== impl Error =====
impl Error {
/// Creates an error representing a shutdown timer.
pub fn shutdown() -> Error {
Error(Shutdown)
}
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | ce0e9c67cfe61c7a91a284331ecc53fa01c32879 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce0e9c67cfe61c7a91a284331ecc53fa01c32879/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | //! Time error types.
use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 575938d4579e6fe6a89b700aadb0ae2bbab5483b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/575938d4579e6fe6a89b700aadb0ae2bbab5483b/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | }
/// Error returned by `Timeout`.
#[derive(Debug, PartialEq)]
#[non_exhaustive]
pub struct Elapsed;
#[derive(Debug)]
pub(crate) enum InsertError {
Elapsed,
}
// ===== impl Error =====
impl Error {
/// Creates an error representing a shutdown timer.
pub fn shutdown() -> Error {
Error(Shutdown)
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 575938d4579e6fe6a89b700aadb0ae2bbab5483b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/575938d4579e6fe6a89b700aadb0ae2bbab5483b/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:3 | /// Returns `true` if the error was caused by the timer being misconfigured.
pub fn is_invalid(&self) -> bool {
matches!(self.0, Kind::Invalid)
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::Kind::*;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 575938d4579e6fe6a89b700aadb0ae2bbab5483b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/575938d4579e6fe6a89b700aadb0ae2bbab5483b/tokio/src/time/error.rs | 81 | 115 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | //! Time error types.
use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 0893841f31542b2b04c5050a8a4a3c45cf867e55 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | #[derive(Debug)]
pub(crate) enum InsertError {
Elapsed,
Invalid,
}
// ===== impl Error =====
impl Error {
/// Creates an error representing a shutdown timer.
pub fn shutdown() -> Error {
Error(Shutdown)
}
/// Returns `true` if the error was caused by the timer being shutdown.
pub ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 0893841f31542b2b04c5050a8a4a3c45cf867e55 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:3 | self.0 as u8
}
pub(crate) fn from_u8(n: u8) -> Self {
Error(match n {
1 => Shutdown,
2 => AtCapacity,
3 => Invalid,
_ => panic!("u8 does not correspond to any time error variant"),
})
}
}
impl error::Error for Error {}
impl fmt::Display for ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 0893841f31542b2b04c5050a8a4a3c45cf867e55 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/error.rs | 81 | 128 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the operation will never b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 60d81bbe10faf344ea18438a1c5ecb9173e6ec52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | /// Returns `true` if the error was caused by the timer being shutdown.
pub fn is_shutdown(&self) -> bool {
matches!(self.0, Kind::Shutdown)
}
/// Creates an error representing a timer at capacity.
pub fn at_capacity() -> Error {
Error(AtCapacity)
}
/// Returns `true` if the er... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 60d81bbe10faf344ea18438a1c5ecb9173e6ec52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/error.rs | 41 | 92 |
tokio-rs/tokio:tokio/src/time/error.rs:3 | impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::Kind::*;
let descr = match self.0 {
Shutdown => "the timer is shutdown, must be called from the context of Tokio runtime",
AtCapacity => "timer is at capacity and cannot creat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 60d81bbe10faf344ea18438a1c5ecb9173e6ec52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/error.rs | 81 | 92 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the operation will never b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | b704c53b9cc76eaf8c9c6585f8444c4515d27728 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the operation will never b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | d1744bf260384838e00311230faf7787a97f477b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1744bf260384838e00311230faf7787a97f477b/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | /// Returns `true` if the error was caused by the timer being shutdown.
pub fn is_shutdown(&self) -> bool {
match self.0 {
Kind::Shutdown => true,
_ => false,
}
}
/// Creates an error representing a timer at capacity.
pub fn at_capacity() -> Error {
Error... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | d1744bf260384838e00311230faf7787a97f477b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1744bf260384838e00311230faf7787a97f477b/tokio/src/time/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/error.rs:3 | 1 => Shutdown,
2 => AtCapacity,
3 => Invalid,
_ => panic!("u8 does not correspond to any time error variant"),
})
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::Kind::*;... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | d1744bf260384838e00311230faf7787a97f477b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1744bf260384838e00311230faf7787a97f477b/tokio/src/time/error.rs | 81 | 101 |
tokio-rs/tokio:tokio/src/time/error.rs:1 | use self::Kind::*;
use std::error;
use std::fmt;
/// Errors encountered by the timer implementation.
///
/// Currently, there are two different errors that can occur:
///
/// * `shutdown` occurs when a timer operation is attempted, but the timer
/// instance has been dropped. In this case, the operation will never b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 9eca96aa214cb8e2fd695cbed179f93826b3ef46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9eca96aa214cb8e2fd695cbed179f93826b3ef46/tokio/src/time/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | match self.0 {
Kind::Shutdown => true,
_ => false,
}
}
/// Creates an error representing a timer at capacity.
pub fn at_capacity() -> Error {
Error(AtCapacity)
}
/// Returns `true` if the error was caused by the timer being at capacity.
pub fn is_at_capa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | 9eca96aa214cb8e2fd695cbed179f93826b3ef46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9eca96aa214cb8e2fd695cbed179f93826b3ef46/tokio/src/time/error.rs | 41 | 72 |
tokio-rs/tokio:tokio/src/time/error.rs:2 | match self.0 {
Kind::Shutdown => true,
_ => false,
}
}
/// Creates an error representing a timer at capacity.
pub fn at_capacity() -> Error {
Error(AtCapacity)
}
/// Returns `true` if the error was caused by the timer being at capacity.
pub fn is_at_capa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/error.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/error.rs | 41 | 72 |
tokio-rs/tokio:tokio/src/time/instant.rs:1 | #![allow(clippy::trivially_copy_pass_by_ref)]
use std::fmt;
use std::ops;
use std::time::Duration;
/// A measurement of a monotonically nondecreasing clock.
/// Opaque and useful only with `Duration`.
///
/// Instants are always guaranteed to be no less than any previously measured
/// instant when created, and are o... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/instant.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/instant.rs:2 | /// # Examples
///
/// ```
/// use tokio::time::Instant;
///
/// let now = Instant::now();
/// ```
pub fn now() -> Instant {
variant::now()
}
/// Create a `tokio::time::Instant` from a `std::time::Instant`.
pub fn from_std(std: std::time::Instant) -> Instant {
In... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/instant.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/instant.rs:4 | /// # Examples
///
/// ```
/// use tokio::time::{Duration, Instant, sleep};
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let instant = Instant::now();
/// let three_secs = Duration::from_secs(3);
/// sleep(three_secs).await;
/// assert!(instant.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/instant.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/instant.rs:5 | time.into_std()
}
}
impl ops::Add<Duration> for Instant {
type Output = Instant;
fn add(self, other: Duration) -> Instant {
Instant::from_std(self.std + other)
}
}
impl ops::AddAssign<Duration> for Instant {
fn add_assign(&mut self, rhs: Duration) {
*self = *self + rhs;
}
}
i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/instant.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/instant.rs:6 | impl fmt::Debug for Instant {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
self.std.fmt(fmt)
}
}
#[cfg(not(feature = "test-util"))]
mod variant {
use super::Instant;
pub(super) fn now() -> Instant {
Instant::from_std(std::time::Instant::now())
}
}
#[cfg(feature = "... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/instant.rs | 201 | 223 |
tokio-rs/tokio:tokio/src/time/instant.rs:2 | /// # Examples
///
/// ```
/// use tokio::time::Instant;
///
/// let now = Instant::now();
/// ```
pub fn now() -> Instant {
variant::now()
}
/// Create a `tokio::time::Instant` from a `std::time::Instant`.
pub fn from_std(std: std::time::Instant) -> Instant {
In... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | d08578fc9a950c8ee0ef242dbce0fcaaed5e853f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d08578fc9a950c8ee0ef242dbce0fcaaed5e853f/tokio/src/time/instant.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/instant.rs:4 | /// # Examples
///
/// ```
/// use tokio::time::{Duration, Instant, sleep};
///
/// #[tokio::main]
/// async fn main() {
/// let instant = Instant::now();
/// let three_secs = Duration::from_secs(3);
/// sleep(three_secs).await;
/// assert!(instant.elapsed() >= th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | d08578fc9a950c8ee0ef242dbce0fcaaed5e853f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d08578fc9a950c8ee0ef242dbce0fcaaed5e853f/tokio/src/time/instant.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/instant.rs:5 | time.into_std()
}
}
impl ops::Add<Duration> for Instant {
type Output = Instant;
fn add(self, other: Duration) -> Instant {
Instant::from_std(self.std + other)
}
}
impl ops::AddAssign<Duration> for Instant {
fn add_assign(&mut self, rhs: Duration) {
*self = *self + rhs;
}
}
i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | fc4deaa1d0e35d3404d1d32ddcb4b083081355c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc4deaa1d0e35d3404d1d32ddcb4b083081355c0/tokio/src/time/instant.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/instant.rs:2 | /// # Examples
///
/// ```
/// use tokio::time::Instant;
///
/// let now = Instant::now();
/// ```
pub fn now() -> Instant {
variant::now()
}
/// Create a `tokio::time::Instant` from a `std::time::Instant`.
pub fn from_std(std: std::time::Instant) -> Instant {
In... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 60bd40d52973690c1e58855bbae6aa2136512fb6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60bd40d52973690c1e58855bbae6aa2136512fb6/tokio/src/time/instant.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/instant.rs:4 | /// Returns the amount of time elapsed since this instant was created.
///
/// # Panics
///
/// This function may panic if the current time is earlier than this
/// instant, which is something that can happen if an `Instant` is
/// produced synthetically.
///
/// # Examples
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 60bd40d52973690c1e58855bbae6aa2136512fb6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60bd40d52973690c1e58855bbae6aa2136512fb6/tokio/src/time/instant.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/instant.rs:5 | impl From<std::time::Instant> for Instant {
fn from(time: std::time::Instant) -> Instant {
Instant::from_std(time)
}
}
impl From<Instant> for std::time::Instant {
fn from(time: Instant) -> std::time::Instant {
time.into_std()
}
}
impl ops::Add<Duration> for Instant {
type Output = ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 60bd40d52973690c1e58855bbae6aa2136512fb6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60bd40d52973690c1e58855bbae6aa2136512fb6/tokio/src/time/instant.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/instant.rs:6 | }
impl ops::SubAssign<Duration> for Instant {
fn sub_assign(&mut self, rhs: Duration) {
*self = *self - rhs;
}
}
impl fmt::Debug for Instant {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
self.std.fmt(fmt)
}
}
#[cfg(not(feature = "test-util"))]
mod variant {
use su... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 60bd40d52973690c1e58855bbae6aa2136512fb6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60bd40d52973690c1e58855bbae6aa2136512fb6/tokio/src/time/instant.rs | 201 | 231 |
tokio-rs/tokio:tokio/src/time/instant.rs:1 | #![allow(clippy::trivially_copy_pass_by_ref)]
use std::fmt;
use std::ops;
use std::time::Duration;
/// A measurement of a monotonically nondecreasing clock.
/// Opaque and useful only with `Duration`.
///
/// Instants are always guaranteed to be no less than any previously measured
/// instant when created, and are o... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | ec99e61945ae46edcb2ee3f282f49f661b63dcd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec99e61945ae46edcb2ee3f282f49f661b63dcd0/tokio/src/time/instant.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/instant.rs:2 | /// # Examples
///
/// ```
/// use tokio::time::Instant;
///
/// let now = Instant::now();
/// ```
pub fn now() -> Instant {
variant::now()
}
/// Create a `tokio::time::Instant` from a `std::time::Instant`.
pub fn from_std(std: std::time::Instant) -> Instant {
In... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | ec99e61945ae46edcb2ee3f282f49f661b63dcd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec99e61945ae46edcb2ee3f282f49f661b63dcd0/tokio/src/time/instant.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/instant.rs:4 | /// # Examples
///
/// ```
/// use tokio::time::{Duration, Instant, sleep};
///
/// #[tokio::main]
/// async fn main() {
/// let instant = Instant::now();
/// let three_secs = Duration::from_secs(3);
/// sleep(three_secs).await;
/// assert!(instant.elapsed() >= th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | ec99e61945ae46edcb2ee3f282f49f661b63dcd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec99e61945ae46edcb2ee3f282f49f661b63dcd0/tokio/src/time/instant.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/instant.rs:5 | time.into_std()
}
}
impl ops::Add<Duration> for Instant {
type Output = Instant;
fn add(self, other: Duration) -> Instant {
Instant::from_std(self.std + other)
}
}
impl ops::AddAssign<Duration> for Instant {
fn add_assign(&mut self, rhs: Duration) {
*self = *self + rhs;
}
}
i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | ec99e61945ae46edcb2ee3f282f49f661b63dcd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec99e61945ae46edcb2ee3f282f49f661b63dcd0/tokio/src/time/instant.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/time/instant.rs:1 | #![allow(clippy::trivially_copy_pass_by_ref)]
use std::fmt;
use std::ops;
use std::time::Duration;
/// A measurement of the system clock, useful for talking to
/// external entities like the file system or other processes.
#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct Instant {
std: std:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/instant.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/instant.rs:3 | /// println!("{:?}", new_now.saturating_duration_since(now));
/// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns
/// }
/// ```
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
self.std.saturating_duration_since(earlier.std)
}
/// Returns ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/instant.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/instant.rs:4 | /// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be
/// represented as `Instant` (which means it's inside the bounds of the
/// underlying data structure), `None` otherwise.
pub fn checked_sub(&self, duration: Duration) -> Option<Instant> {
self.std.checked_sub(duration).map(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/instant.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/instant.rs:5 | }
impl ops::Sub<Duration> for Instant {
type Output = Instant;
fn sub(self, rhs: Duration) -> Instant {
Instant::from_std(self.std - rhs)
}
}
impl ops::SubAssign<Duration> for Instant {
fn sub_assign(&mut self, rhs: Duration) {
*self = *self - rhs;
}
}
impl fmt::Debug for Instant... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/instant.rs | 161 | 199 |
tokio-rs/tokio:tokio/src/time/instant.rs:1 | #![allow(clippy::trivially_copy_pass_by_ref)]
use std::fmt;
use std::ops;
use std::time::Duration;
/// A measurement of the system clock, useful for talking to
/// external entities like the file system or other processes.
#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct Instant {
std: std:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 41576e6c48c38e0d8418997defb7413484a5c5c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/41576e6c48c38e0d8418997defb7413484a5c5c5/tokio/src/time/instant.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/instant.rs:3 | /// println!("{:?}", new_now.saturating_duration_since(now));
/// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns
/// }
/// ```
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
self.std.saturating_duration_since(earlier.std)
}
/// Returns ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 41576e6c48c38e0d8418997defb7413484a5c5c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/41576e6c48c38e0d8418997defb7413484a5c5c5/tokio/src/time/instant.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/instant.rs:1 | #![allow(clippy::trivially_copy_pass_by_ref)]
use std::fmt;
use std::ops;
use std::time::Duration;
/// A measurement of the system clock, useful for talking to
/// external entities like the file system or other processes.
#[derive(Clone, Copy, Eq, PartialEq, PartialOrd)]
pub struct Instant {
std: std::time::Inst... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | c3461b3ef3866f6335596d1882a52343cef0bcb5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3461b3ef3866f6335596d1882a52343cef0bcb5/tokio/src/time/instant.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/time/instant.rs:3 | /// println!("{:?}", new_now.saturating_duration_since(now));
/// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns
/// }
/// ```
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
self.std.saturating_duration_since(earlier.std)
}
/// Returns ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/instant.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/instant.rs:4 | /// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be
/// represented as `Instant` (which means it's inside the bounds of the
/// underlying data structure), `None` otherwise.
pub fn checked_sub(&self, duration: Duration) -> Option<Instant> {
self.std.checked_sub(duration).map(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/instant.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/instant.rs:5 | *self = *self - rhs;
}
}
impl fmt::Debug for Instant {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
self.std.fmt(fmt)
}
}
#[cfg(not(feature = "test-util"))]
mod variant {
use super::Instant;
pub(super) fn now() -> Instant {
Instant::from_std(std::time::Instant::now... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/instant.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/instant.rs | 161 | 187 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// [`Burst`](MissedTickBehavior::Burst), but this can be configured
/// by calling [`set_missed_tick_behavior`](Interval::set_missed_tick_behavior).
///
/// An interval will tick indefinitely. At any time, the [`Interval`] value can
/// be dropped. This cancels the interval.
///
/// # Panics
///
/// This function pani... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/time/interval.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/interval.rs:4 | let resource_span = {
let location = location.expect("should have location if tracing");
tracing::trace_span!(
"runtime.resource",
concrete_type = "Interval",
kind = "timer",
loc.file = location.file(),
loc.line = location.line(),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/time/interval.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/time/interval.rs:9 | /// task_that_takes_75_millis().await;
/// // The `Interval` has missed a tick
///
/// // Since we have exceeded our timeout, this will resolve immediately
/// interval.tick().await;
///
/// // This one will resolve after 25ms, 100ms after the start of
/// // `interval`, which is the closest... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/time/interval.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/time/interval.rs:10 | }
}
}
}
impl Default for MissedTickBehavior {
/// Returns [`MissedTickBehavior::Burst`].
///
/// For most usecases, the [`Burst`] strategy is what is desired.
/// Additionally, to preserve backwards compatibility, the [`Burst`]
/// strategy must be the default. For these reasons,
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/time/interval.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/time/interval.rs:11 | #[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span,
}
impl Interval {
/// Completes when the next instant in the interval has been reached.
///
/// # Cancel safety
///
/// This method is cancellation safe. If `tick` is used as the branch in a `tokio::select!` and
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/time/interval.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/interval.rs:12 | "poll_tick",
false,
);
#[cfg(not(all(tokio_unstable, feature = "tracing")))]
let instant = poll_fn(|cx| self.poll_tick(cx));
instant.await
}
/// Polls for the next instant in the interval to be reached.
///
/// This method can return the following values:
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/time/interval.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/time/interval.rs:13 | } else {
timeout + self.period
};
self.delay.as_mut().reset(next);
// Return the time when we were scheduled to tick
Poll::Ready(timeout)
}
/// Resets the interval to complete one period after the current time.
///
/// This method ignores [`MissedTickBehavi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/time/interval.rs | 481 | 535 |
tokio-rs/tokio:tokio/src/time/interval.rs:14 | /// Returns the [`MissedTickBehavior`] strategy currently being used.
pub fn missed_tick_behavior(&self) -> MissedTickBehavior {
self.missed_tick_behavior
}
/// Sets the [`MissedTickBehavior`] strategy that should be used.
pub fn set_missed_tick_behavior(&mut self, behavior: MissedTickBehavior)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/time/interval.rs | 521 | 535 |
tokio-rs/tokio:tokio/src/time/interval.rs:11 | #[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span,
}
impl Interval {
/// Completes when the next instant in the interval has been reached.
///
/// # Cancel safety
///
/// This method is cancellation safe. If `tick` is used as the branch in a `tokio::select!` and
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | f3e340a35b306e926e78537a0dd65b2e9b9cdc89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/time/interval.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/interval.rs:12 | false,
);
#[cfg(not(all(tokio_unstable, feature = "tracing")))]
let instant = poll_fn(|cx| self.poll_tick(cx));
instant.await
}
/// Polls for the next instant in the interval to be reached.
///
/// This method can return the following values:
///
/// * `Poll::P... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | f3e340a35b306e926e78537a0dd65b2e9b9cdc89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/time/interval.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/time/interval.rs:13 | timeout + self.period
};
self.delay.as_mut().reset(next);
// Return the time when we were scheduled to tick
Poll::Ready(timeout)
}
/// Resets the interval to complete one period after the current time.
///
/// This method ignores [`MissedTickBehavior`] strategy.
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | f3e340a35b306e926e78537a0dd65b2e9b9cdc89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/time/interval.rs | 481 | 534 |
tokio-rs/tokio:tokio/src/time/interval.rs:14 | pub fn missed_tick_behavior(&self) -> MissedTickBehavior {
self.missed_tick_behavior
}
/// Sets the [`MissedTickBehavior`] strategy that should be used.
pub fn set_missed_tick_behavior(&mut self, behavior: MissedTickBehavior) {
self.missed_tick_behavior = behavior;
}
/// Returns th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | f3e340a35b306e926e78537a0dd65b2e9b9cdc89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/time/interval.rs | 521 | 534 |
tokio-rs/tokio:tokio/src/time/interval.rs:9 | /// // Since we have exceeded our timeout, this will resolve immediately
/// interval.tick().await;
///
/// // This one will resolve after 25ms, 100ms after the start of
/// // `interval`, which is the closest multiple of `period` from the start
/// // of `interval` after the call to `tick` up above... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/time/interval.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/time/interval.rs:10 | }
impl Default for MissedTickBehavior {
/// Returns [`MissedTickBehavior::Burst`].
///
/// For most usecases, the [`Burst`] strategy is what is desired.
/// Additionally, to preserve backwards compatibility, the [`Burst`]
/// strategy must be the default. For these reasons,
/// [`MissedTickBeha... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/time/interval.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/time/interval.rs:11 | }
impl Interval {
/// Completes when the next instant in the interval has been reached.
///
/// # Cancel safety
///
/// This method is cancellation safe. If `tick` is used as the branch in a `tokio::select!` and
/// another branch completes first, then no tick has been consumed.
///
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/time/interval.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/time/interval.rs:12 | let instant = poll_fn(|cx| self.poll_tick(cx));
instant.await
}
/// Polls for the next instant in the interval to be reached.
///
/// This method can return the following values:
///
/// * `Poll::Pending` if the next instant has not yet been reached.
/// * `Poll::Ready(instant)` ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/time/interval.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/time/interval.rs:13 | self.delay.as_mut().reset(next);
// Return the time when we were scheduled to tick
Poll::Ready(timeout)
}
/// Resets the interval to complete one period after the current time.
///
/// This method ignores [`MissedTickBehavior`] strategy.
///
/// # Examples
///
/// ```
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/time/interval.rs | 481 | 531 |
tokio-rs/tokio:tokio/src/time/interval.rs:14 | /// Sets the [`MissedTickBehavior`] strategy that should be used.
pub fn set_missed_tick_behavior(&mut self, behavior: MissedTickBehavior) {
self.missed_tick_behavior = behavior;
}
/// Returns the period of the interval.
pub fn period(&self) -> Duration {
self.period
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/time/interval.rs | 521 | 531 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// This function panics if `period` is zero.
///
/// # Examples
///
/// ```
/// use tokio::time::{interval_at, Duration, Instant};
///
/// #[tokio::main]
/// async fn main() {
/// let start = Instant::now() + Duration::from_millis(50);
/// let mut interval = interval_at(start, Duration::from_millis(10));
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 60d81bbe10faf344ea18438a1c5ecb9173e6ec52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/interval.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/interval.rs:4 | period: Duration,
}
impl Interval {
fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
// Wait for the delay to be done
ready!(Pin::new(&mut self.delay).poll(cx));
// Get the `now` by looking at the `delay` deadline
let now = self.delay.deadline();
// The nex... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 60d81bbe10faf344ea18438a1c5ecb9173e6ec52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/interval.rs | 121 | 173 |
tokio-rs/tokio:tokio/src/time/interval.rs:5 | pub async fn tick(&mut self) -> Instant {
poll_fn(|cx| self.poll_tick(cx)).await
}
}
#[cfg(feature = "stream")]
impl crate::stream::Stream for Interval {
type Item = Instant;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Instant>> {
Poll::Ready(Some(ready!(sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 60d81bbe10faf344ea18438a1c5ecb9173e6ec52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/interval.rs | 161 | 173 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// This function panics if `period` is zero.
///
/// # Examples
///
/// ```
/// use tokio::time::{interval_at, Duration, Instant};
///
/// #[tokio::main]
/// async fn main() {
/// let start = Instant::now() + Duration::from_millis(50);
/// let mut interval = interval_at(start, Duration::from_millis(10));
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 7ec6d88b21ea3e5531176f526a51dae0a4513025 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ec6d88b21ea3e5531176f526a51dae0a4513025/tokio/src/time/interval.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// This function panics if `period` is zero.
///
/// # Examples
///
/// ```
/// use tokio::time::{interval_at, Duration, Instant};
///
/// #[tokio::main]
/// async fn main() {
/// let start = Instant::now() + Duration::from_millis(50);
/// let mut interval = interval_at(start, Duration::from_millis(10));
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/interval.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/interval.rs:4 | period: Duration,
}
impl Interval {
#[doc(hidden)] // TODO: document
pub fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
// Wait for the delay to be done
ready!(Pin::new(&mut self.delay).poll(cx));
// Get the `now` by looking at the `delay` deadline
let now = s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/interval.rs | 121 | 174 |
tokio-rs/tokio:tokio/src/time/interval.rs:5 | /// ```
pub async fn tick(&mut self) -> Instant {
poll_fn(|cx| self.poll_tick(cx)).await
}
}
#[cfg(feature = "stream")]
impl crate::stream::Stream for Interval {
type Item = Instant;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Instant>> {
Poll::Ready(Som... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/interval.rs | 161 | 174 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// This function panics if `period` is zero.
///
/// # Examples
///
/// ```
/// use tokio::time::{interval_at, Duration, Instant};
///
/// #[tokio::main]
/// async fn main() {
/// let start = Instant::now() + Duration::from_millis(50);
/// let mut interval = interval_at(start, Duration::from_millis(10));
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 68f7eff39e5adf2246770d7239ed83731297d1f3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68f7eff39e5adf2246770d7239ed83731297d1f3/tokio/src/time/interval.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/interval.rs:4 | period: Duration,
}
impl Interval {
#[doc(hidden)] // TODO: document
pub fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
// Wait for the delay to be done
ready!(Pin::new(&mut self.delay).poll(cx));
// Get the `now` by looking at the `delay` deadline
let now = s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | ff6130da6583188b1ccebfd706eec7f5721976a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ff6130da6583188b1ccebfd706eec7f5721976a3/tokio/src/time/interval.rs | 121 | 175 |
tokio-rs/tokio:tokio/src/time/interval.rs:5 | /// ```
#[allow(clippy::should_implement_trait)] // TODO: rename (tokio-rs/tokio#1261)
pub async fn tick(&mut self) -> Instant {
poll_fn(|cx| self.poll_tick(cx)).await
}
}
#[cfg(feature = "stream")]
impl crate::stream::Stream for Interval {
type Item = Instant;
fn poll_next(mut self: Pin<&... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | ff6130da6583188b1ccebfd706eec7f5721976a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ff6130da6583188b1ccebfd706eec7f5721976a3/tokio/src/time/interval.rs | 161 | 175 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// This function panics if `period` is zero.
///
/// # Examples
///
/// ```
/// use tokio::time::{interval_at, Duration, Instant};
///
/// #[tokio::main]
/// async fn main() {
/// let start = Instant::now() + Duration::from_millis(50);
/// let mut interval = interval_at(start, Duration::from_millis(10));
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 018e345add2c74537136370b6af5eda1b604f3d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/018e345add2c74537136370b6af5eda1b604f3d3/tokio/src/time/interval.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/time/interval.rs:4 | pub fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
// Wait for the delay to be done
ready!(Pin::new(&mut self.delay).poll(cx));
// Get the `now` by looking at the `delay` deadline
let now = self.delay.deadline();
// The next interval value is `duration` after ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 018e345add2c74537136370b6af5eda1b604f3d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/018e345add2c74537136370b6af5eda1b604f3d3/tokio/src/time/interval.rs | 121 | 170 |
tokio-rs/tokio:tokio/src/time/interval.rs:5 | }
#[cfg(feature = "stream")]
impl crate::stream::Stream for Interval {
type Item = Instant;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Instant>> {
Poll::Ready(Some(ready!(self.poll_tick(cx))))
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 018e345add2c74537136370b6af5eda1b604f3d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/018e345add2c74537136370b6af5eda1b604f3d3/tokio/src/time/interval.rs | 161 | 170 |
tokio-rs/tokio:tokio/src/time/interval.rs:2 | /// Creates new `Interval` that yields with interval of `period` with the
/// first tick completing at `at`.
///
/// An interval will tick indefinitely. At any time, the `Interval` value can be
/// dropped. This cancels the interval.
///
/// # Panics
///
/// This function panics if `period` is zero.
///
/// # Examples
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | f309b295bb0bdee5862a0ab8359a5f0622a588b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f309b295bb0bdee5862a0ab8359a5f0622a588b9/tokio/src/time/interval.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// Future that completes the next time the `Interval` yields a value.
delay: Delay,
/// The duration between values yielded by `Interval`.
period: Duration,
}
impl Interval {
#[doc(hidden)] // TODO: document
pub fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
// Wait for ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | f309b295bb0bdee5862a0ab8359a5f0622a588b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f309b295bb0bdee5862a0ab8359a5f0622a588b9/tokio/src/time/interval.rs | 81 | 139 |
tokio-rs/tokio:tokio/src/time/interval.rs:4 | /// interval.tick().await;
///
/// // approximately 20ms have elapsed.
/// }
/// ```
#[allow(clippy::should_implement_trait)] // TODO: rename (tokio-rs/tokio#1261)
pub async fn tick(&mut self) -> Instant {
poll_fn(|cx| self.poll_tick(cx)).await
}
}
#[cfg(feature = "stream")]... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | f309b295bb0bdee5862a0ab8359a5f0622a588b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f309b295bb0bdee5862a0ab8359a5f0622a588b9/tokio/src/time/interval.rs | 121 | 139 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// Future that completes the next time the `Interval` yields a value.
delay: Delay,
/// The duration between values yielded by `Interval`.
period: Duration,
}
impl Interval {
#[doc(hidden)] // TODO: document
pub fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
// Wait for ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 4c645866ef4ea5b0ef8c7852281a09b2f96d969b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4c645866ef4ea5b0ef8c7852281a09b2f96d969b/tokio/src/time/interval.rs | 81 | 139 |
tokio-rs/tokio:tokio/src/time/interval.rs:4 | /// interval.tick().await;
///
/// // approximately 30ms have elapsed.
/// }
/// ```
#[allow(clippy::should_implement_trait)] // TODO: rename (tokio-rs/tokio#1261)
pub async fn tick(&mut self) -> Instant {
poll_fn(|cx| self.poll_tick(cx)).await
}
}
#[cfg(feature = "stream")]... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | 4c645866ef4ea5b0ef8c7852281a09b2f96d969b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4c645866ef4ea5b0ef8c7852281a09b2f96d969b/tokio/src/time/interval.rs | 121 | 139 |
tokio-rs/tokio:tokio/src/time/interval.rs:3 | /// Future that completes the next time the `Interval` yields a value.
delay: Delay,
/// The duration between values yielded by `Interval`.
period: Duration,
}
impl Interval {
#[doc(hidden)] // TODO: document
pub fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
// Wait for ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/time/interval.rs | MIT | bc150cd0b56cf6dcb7c4feab64e83b9938faa186 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bc150cd0b56cf6dcb7c4feab64e83b9938faa186/tokio/src/time/interval.rs | 81 | 139 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.