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/sleep.rs:10
#[cfg(all(tokio_unstable, feature = "tracing"))] { let _resource_enter = me.inner.ctx.resource_span.enter(); me.inner.ctx.async_op_span = tracing::trace_span!("runtime.resource.async_op", source = "Sleep::reset"); let _async_op_enter = me.inner.ctx.async_op_sp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
7483509746e1d82d7fc3642fd8431116c96aa387
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7483509746e1d82d7fc3642fd8431116c96aa387/tokio/src/time/sleep.rs
361
420
tokio-rs/tokio:tokio/src/time/sleep.rs:7
} cfg_not_trace! { #[derive(Debug)] struct Inner { deadline: Instant, } } impl Sleep { #[cfg_attr(not(all(tokio_unstable, feature = "tracing")), allow(unused_variables))] #[track_caller] pub(crate) fn new_timeout( deadline: Instant, location: Option<&'static Location<'s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
cb67f28fe3c99956959669277fde889bc2dc252e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cb67f28fe3c99956959669277fde889bc2dc252e/tokio/src/time/sleep.rs
241
300
tokio-rs/tokio:tokio/src/time/sleep.rs:6
/// use tokio::time::Sleep; /// use pin_project_lite::pin_project; /// /// pin_project! { /// struct HasSleep { /// #[pin] /// sleep: Sleep, /// } /// } /// /// impl Future for HasSleep { /// type Output = (); /// /// fn poll(self: Pin<...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
80568dfc6da83f9c68c63bd9de66bcda295c76a9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/80568dfc6da83f9c68c63bd9de66bcda295c76a9/tokio/src/time/sleep.rs
201
260
tokio-rs/tokio:tokio/src/time/sleep.rs:7
} cfg_not_trace! { #[derive(Debug)] struct Inner { deadline: Instant, } } impl Sleep { cfg_rt! { #[cfg_attr(not(all(tokio_unstable, feature = "tracing")), allow(unused_variables))] #[track_caller] pub(crate) fn new_timeout( deadline: Instant, loc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
80568dfc6da83f9c68c63bd9de66bcda295c76a9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/80568dfc6da83f9c68c63bd9de66bcda295c76a9/tokio/src/time/sleep.rs
241
300
tokio-rs/tokio:tokio/src/time/sleep.rs:8
tracing::trace!( target: "runtime::resource::state_update", duration = duration, duration.unit = "ms", duration.op = "override", ); tracing::trace_span!("runtime.resource.async_op", s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
80568dfc6da83f9c68c63bd9de66bcda295c76a9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/80568dfc6da83f9c68c63bd9de66bcda295c76a9/tokio/src/time/sleep.rs
281
340
tokio-rs/tokio:tokio/src/time/sleep.rs:9
} pub(crate) fn far_future(location: Option<&'static Location<'static>>) -> Sleep { Self::new_timeout(Instant::far_future(), location) } /// Returns the instant at which the future will complete. pub fn deadline(&self) -> Instant { self.inner.deadline } /// Returns `true` if `...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
80568dfc6da83f9c68c63bd9de66bcda295c76a9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/80568dfc6da83f9c68c63bd9de66bcda295c76a9/tokio/src/time/sleep.rs
321
380
tokio-rs/tokio:tokio/src/time/sleep.rs:10
/// sleep.as_mut().reset(Instant::now() + Duration::from_millis(20)); /// # } /// ``` /// /// See also the top-level examples. /// /// [`Pin::as_mut`]: fn@std::pin::Pin::as_mut pub fn reset(self: Pin<&mut Self>, deadline: Instant) { self.reset_inner(deadline) } fn reset_inne...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
80568dfc6da83f9c68c63bd9de66bcda295c76a9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/80568dfc6da83f9c68c63bd9de66bcda295c76a9/tokio/src/time/sleep.rs
361
420
tokio-rs/tokio:tokio/src/time/sleep.rs:11
} fn poll_elapsed(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Result<(), Error>> { let me = self.project(); // Keep track of task budget #[cfg(all(tokio_unstable, feature = "tracing"))] let coop = ready!(trace_poll_op!( "poll_elapsed", crate::c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
80568dfc6da83f9c68c63bd9de66bcda295c76a9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/80568dfc6da83f9c68c63bd9de66bcda295c76a9/tokio/src/time/sleep.rs
401
453
tokio-rs/tokio:tokio/src/time/sleep.rs:6
/// use std::pin::Pin; /// use std::task::{Context, Poll}; /// use tokio::time::Sleep; /// use pin_project_lite::pin_project; /// /// pin_project! { /// struct HasSleep { /// #[pin] /// sleep: Sleep, /// } /// } /// /// impl Future for HasSleep { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
ebeb78ed40027032feb77c89a1de4b58d2dcafbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/time/sleep.rs
201
260
tokio-rs/tokio:tokio/src/time/sleep.rs:7
ctx: trace::AsyncOpTracingCtx, time_source: TimeSource, } } cfg_not_trace! { #[derive(Debug)] struct Inner { deadline: Instant, } } impl Sleep { cfg_rt! { #[cfg_attr(not(all(tokio_unstable, feature = "tracing")), allow(unused_variables))] #[track_caller] pub...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
ebeb78ed40027032feb77c89a1de4b58d2dcafbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/time/sleep.rs
241
300
tokio-rs/tokio:tokio/src/time/sleep.rs:8
); let async_op_span = resource_span.in_scope(|| { tracing::trace!( target: "runtime::resource::state_update", duration = duration, duration.unit = "ms", duration.op = "override", ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
ebeb78ed40027032feb77c89a1de4b58d2dcafbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/time/sleep.rs
281
340
tokio-rs/tokio:tokio/src/time/sleep.rs:9
_location: Option<&'static Location<'static>>, ) -> Sleep { panic!("{}", crate::util::error::CONTEXT_MISSING_ERROR) } } pub(crate) fn far_future(location: Option<&'static Location<'static>>) -> Sleep { Self::new_timeout(Instant::far_future(), location) } /// Returns...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
ebeb78ed40027032feb77c89a1de4b58d2dcafbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/time/sleep.rs
321
380
tokio-rs/tokio:tokio/src/time/sleep.rs:10
/// # async fn main() { /// let sleep = tokio::time::sleep(Duration::from_millis(10)); /// tokio::pin!(sleep); /// /// sleep.as_mut().reset(Instant::now() + Duration::from_millis(20)); /// # } /// ``` /// /// See also the top-level examples. /// /// [`Pin::as_mut`]: fn@std::pin::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
ebeb78ed40027032feb77c89a1de4b58d2dcafbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/time/sleep.rs
361
420
tokio-rs/tokio:tokio/src/time/sleep.rs:11
duration.op = "override", ); } } fn poll_elapsed(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Result<(), Error>> { let me = self.project(); // Keep track of task budget #[cfg(all(tokio_unstable, feature = "tracing"))] let coop = ready!(trace_pol...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
ebeb78ed40027032feb77c89a1de4b58d2dcafbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/time/sleep.rs
401
456
tokio-rs/tokio:tokio/src/time/sleep.rs:12
// Both cases are extremely rare, and pretty accurately fit into // "logic errors", so we just panic in this case. A user couldn't // really do much better if we passed the error onwards. fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> { #[cfg(all(tokio_unstable, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
ebeb78ed40027032feb77c89a1de4b58d2dcafbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/time/sleep.rs
441
456
tokio-rs/tokio:tokio/src/time/sleep.rs:6
/// use std::future::Future; /// use std::pin::Pin; /// use std::task::{Context, Poll}; /// use tokio::time::Sleep; /// use pin_project_lite::pin_project; /// /// pin_project! { /// struct HasSleep { /// #[pin] /// sleep: Sleep, /// } /// } /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
588408c06000313f7b4f31c225d3635e9b012e3f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/588408c06000313f7b4f31c225d3635e9b012e3f/tokio/src/time/sleep.rs
201
260
tokio-rs/tokio:tokio/src/time/sleep.rs:7
deadline: Instant, ctx: trace::AsyncOpTracingCtx, time_source: TimeSource, } } cfg_not_trace! { #[derive(Debug)] struct Inner { deadline: Instant, } } impl Sleep { #[cfg_attr(not(all(tokio_unstable, feature = "tracing")), allow(unused_variables))] #[track_caller] pu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
588408c06000313f7b4f31c225d3635e9b012e3f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/588408c06000313f7b4f31c225d3635e9b012e3f/tokio/src/time/sleep.rs
241
300
tokio-rs/tokio:tokio/src/time/sleep.rs:8
let async_op_span = resource_span.in_scope(|| { tracing::trace!( target: "runtime::resource::state_update", duration = duration, duration.unit = "ms", duration.op = "override", ); tracing::tr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
588408c06000313f7b4f31c225d3635e9b012e3f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/588408c06000313f7b4f31c225d3635e9b012e3f/tokio/src/time/sleep.rs
281
340
tokio-rs/tokio:tokio/src/time/sleep.rs:9
} /// Returns `true` if `Sleep` has elapsed. /// /// A `Sleep` instance is elapsed when the requested duration has elapsed. pub fn is_elapsed(&self) -> bool { self.entry.is_elapsed() } /// Resets the `Sleep` instance to a new deadline. /// /// Calling this function allows chang...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
588408c06000313f7b4f31c225d3635e9b012e3f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/588408c06000313f7b4f31c225d3635e9b012e3f/tokio/src/time/sleep.rs
321
380
tokio-rs/tokio:tokio/src/time/sleep.rs:10
} fn reset_inner(self: Pin<&mut Self>, deadline: Instant) { let me = self.project(); me.entry.reset(deadline); (*me.inner).deadline = deadline; #[cfg(all(tokio_unstable, feature = "tracing"))] { let _resource_enter = me.inner.ctx.resource_span.enter(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
588408c06000313f7b4f31c225d3635e9b012e3f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/588408c06000313f7b4f31c225d3635e9b012e3f/tokio/src/time/sleep.rs
361
420
tokio-rs/tokio:tokio/src/time/sleep.rs:11
)); #[cfg(any(not(tokio_unstable), not(feature = "tracing")))] let coop = ready!(crate::coop::poll_proceed(cx)); let result = me.entry.poll_elapsed(cx).map(move |r| { coop.made_progress(); r }); #[cfg(all(tokio_unstable, feature = "tracing"))] r...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
588408c06000313f7b4f31c225d3635e9b012e3f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/588408c06000313f7b4f31c225d3635e9b012e3f/tokio/src/time/sleep.rs
401
443
tokio-rs/tokio:tokio/src/time/sleep.rs:6
/// use std::pin::Pin; /// use std::task::{Context, Poll}; /// use tokio::time::Sleep; /// use pin_project_lite::pin_project; /// /// pin_project! { /// struct HasSleep { /// #[pin] /// sleep: Sleep, /// } /// } /// /// impl Future for HasSleep { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
2ad347465e8b634b785e7637d899a14da8a0fba3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ad347465e8b634b785e7637d899a14da8a0fba3/tokio/src/time/sleep.rs
201
260
tokio-rs/tokio:tokio/src/time/sleep.rs:7
ctx: trace::AsyncOpTracingCtx, time_source: TimeSource, } } cfg_not_trace! { #[derive(Debug)] struct Inner { deadline: Instant, } } impl Sleep { #[cfg_attr(not(all(tokio_unstable, feature = "tracing")), allow(unused_variables))] #[track_caller] pub(crate) fn new_timeout( ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
2ad347465e8b634b785e7637d899a14da8a0fba3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ad347465e8b634b785e7637d899a14da8a0fba3/tokio/src/time/sleep.rs
241
300
tokio-rs/tokio:tokio/src/time/sleep.rs:8
target: "runtime::resource::state_update", duration = duration, duration.unit = "ms", duration.op = "override", ); tracing::trace_span!("runtime.resource.async_op", source = "Sleep::new_timeout") }); le...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
2ad347465e8b634b785e7637d899a14da8a0fba3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ad347465e8b634b785e7637d899a14da8a0fba3/tokio/src/time/sleep.rs
281
340
tokio-rs/tokio:tokio/src/time/sleep.rs:9
/// Returns `true` if `Sleep` has elapsed. /// /// A `Sleep` instance is elapsed when the requested duration has elapsed. pub fn is_elapsed(&self) -> bool { self.entry.is_elapsed() } /// Resets the `Sleep` instance to a new deadline. /// /// Calling this function allows changing the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
2ad347465e8b634b785e7637d899a14da8a0fba3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ad347465e8b634b785e7637d899a14da8a0fba3/tokio/src/time/sleep.rs
321
380
tokio-rs/tokio:tokio/src/time/sleep.rs:10
fn reset_inner(self: Pin<&mut Self>, deadline: Instant) { let me = self.project(); me.entry.reset(deadline); (*me.inner).deadline = deadline; #[cfg(all(tokio_unstable, feature = "tracing"))] { let _resource_enter = me.inner.ctx.resource_span.enter(); me.i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
2ad347465e8b634b785e7637d899a14da8a0fba3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ad347465e8b634b785e7637d899a14da8a0fba3/tokio/src/time/sleep.rs
361
420
tokio-rs/tokio:tokio/src/time/sleep.rs:11
#[cfg(any(not(tokio_unstable), not(feature = "tracing")))] let coop = ready!(crate::coop::poll_proceed(cx)); let result = me.entry.poll_elapsed(cx).map(move |r| { coop.made_progress(); r }); #[cfg(all(tokio_unstable, feature = "tracing"))] return trace_p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
2ad347465e8b634b785e7637d899a14da8a0fba3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ad347465e8b634b785e7637d899a14da8a0fba3/tokio/src/time/sleep.rs
401
441
tokio-rs/tokio:tokio/src/time/sleep.rs:2
/// # Examples /// /// Wait 100ms and print "100 ms have elapsed". /// /// ``` /// use tokio::time::{sleep, Duration}; /// /// #[tokio::main] /// async fn main() { /// sleep(Duration::from_millis(100)).await; /// println!("100 ms have elapsed"); /// } /// ``` /// /// [`interval`]: crate::time::interval() pub fn...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
9d0c0dd22cfa028af63798671c781b1fd83562e2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d0c0dd22cfa028af63798671c781b1fd83562e2/tokio/src/time/sleep.rs
41
100
tokio-rs/tokio:tokio/src/time/sleep.rs:3
self.entry.time_ref().deadline } /// Returns `true` if `Sleep` has elapsed. /// /// A `Sleep` instance is elapsed when the requested duration has elapsed. pub fn is_elapsed(&self) -> bool { self.entry.is_elapsed() } /// Resets the `Sleep` instance to a new deadline. /// ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
9d0c0dd22cfa028af63798671c781b1fd83562e2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d0c0dd22cfa028af63798671c781b1fd83562e2/tokio/src/time/sleep.rs
81
140
tokio-rs/tokio:tokio/src/time/sleep.rs:4
// `poll_elapsed` can return an error in two cases: // // - AtCapacity: this is a pathological case where far too many // sleep instances have been scheduled. // - Shutdown: No timer has been setup, which is a mis-use error. // // Both cases are extremely rare, and pret...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
9d0c0dd22cfa028af63798671c781b1fd83562e2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d0c0dd22cfa028af63798671c781b1fd83562e2/tokio/src/time/sleep.rs
121
141
tokio-rs/tokio:tokio/src/time/sleep.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/sleep.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/sleep.rs
41
100
tokio-rs/tokio:tokio/src/time/sleep.rs:3
/// Returns `true` if `Sleep` has elapsed. /// /// A `Sleep` instance is elapsed when the requested duration has elapsed. pub fn is_elapsed(&self) -> bool { self.entry.is_elapsed() } /// Resets the `Sleep` instance to a new deadline. /// /// Calling this function allows changing the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/sleep.rs
81
139
tokio-rs/tokio:tokio/src/time/sleep.rs:4
// - AtCapacity: this is a pathological case where far too many // sleep instances have been scheduled. // - Shutdown: No timer has been setup, which is a mis-use error. // // Both cases are extremely rare, and pretty accurately fit into // "logic errors", so we just panic in t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/sleep.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/sleep.rs
121
139
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:1
use crate::park::{Park, Unpark}; use crate::runtime::context; use crate::time::driver::Driver; use crate::time::{Clock, Duration, Instant}; use std::marker::PhantomData; use std::rc::Rc; use std::sync::{Arc, Mutex}; /// Run the provided closure with a `MockClock` that starts at the current time. pub(crate) fn mock<F,...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
a515f9c459d662b9c93d962812dc1fd8d1b32e08
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a515f9c459d662b9c93d962812dc1fd8d1b32e08/tokio/src/time/tests/mock_clock.rs
1
60
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:2
inner: Inner, _pd: PhantomData<Rc<()>>, } #[derive(Debug)] struct MockNow { inner: Inner, } #[derive(Debug)] struct MockPark { inner: Inner, _pd: PhantomData<Rc<()>>, } #[derive(Debug)] struct MockUnpark { inner: Inner, } #[derive(Debug)] struct State { clock: Clock, unparked: bool, ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
a515f9c459d662b9c93d962812dc1fd8d1b32e08
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a515f9c459d662b9c93d962812dc1fd8d1b32e08/tokio/src/time/tests/mock_clock.rs
41
100
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:3
{ let park = self.time.mock_park(); let timer = Driver::new(park, self.clock.clone()); let handle = timer.handle(); let ctx = context::ThreadContext::clone_current(); let _e = ctx .with_clock(self.clock.clone()) .with_time_handle(Some(handle)) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
a515f9c459d662b9c93d962812dc1fd8d1b32e08
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a515f9c459d662b9c93d962812dc1fd8d1b32e08/tokio/src/time/tests/mock_clock.rs
81
140
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:4
let end = now + duration; while Instant::now() < end { self.turn_for(end - Instant::now()); } } /// Returns the total amount of time the time has been advanced. pub(crate) fn advanced(&self) -> Duration { self.clock.advanced() } /// Get the currently mocked tim...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
a515f9c459d662b9c93d962812dc1fd8d1b32e08
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a515f9c459d662b9c93d962812dc1fd8d1b32e08/tokio/src/time/tests/mock_clock.rs
121
180
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:5
let inner = self.inner.clone(); MockPark { inner, _pd: PhantomData, } } pub(crate) fn now(&self) -> Instant { Instant::now() } } impl State {} impl Park for MockPark { type Unpark = MockUnpark; type Error = (); fn unpark(&self) -> Self::Unpark ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
a515f9c459d662b9c93d962812dc1fd8d1b32e08
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a515f9c459d662b9c93d962812dc1fd8d1b32e08/tokio/src/time/tests/mock_clock.rs
161
212
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:6
Ok(()) } } impl Unpark for MockUnpark { fn unpark(&self) { if let Ok(mut inner) = self.inner.lock() { inner.unparked = true; } } }
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
a515f9c459d662b9c93d962812dc1fd8d1b32e08
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a515f9c459d662b9c93d962812dc1fd8d1b32e08/tokio/src/time/tests/mock_clock.rs
201
212
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:2
inner: Inner, _pd: PhantomData<Rc<()>>, } #[derive(Debug)] struct MockNow { inner: Inner, } #[derive(Debug)] struct MockPark { inner: Inner, _pd: PhantomData<Rc<()>>, } #[derive(Debug)] struct MockUnpark { inner: Inner, } #[derive(Debug)] struct State { clock: Clock, unparked: bool, ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
67bf9c36f347031ca05872d102a7f9abc8b465f0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67bf9c36f347031ca05872d102a7f9abc8b465f0/tokio/src/time/tests/mock_clock.rs
41
100
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:3
{ let park = self.time.mock_park(); let timer = Driver::new(park, self.clock.clone()); let handle = timer.handle(); let ctx = context::ThreadContext::clone_current(); let _e = ctx .with_clock(self.clock.clone()) .with_time_handle(Some(handle.clone())) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
67bf9c36f347031ca05872d102a7f9abc8b465f0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67bf9c36f347031ca05872d102a7f9abc8b465f0/tokio/src/time/tests/mock_clock.rs
81
140
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:1
use crate::park::{Park, Unpark}; use crate::time::driver::{self, Driver}; use crate::time::{Clock, Duration, Instant}; use std::marker::PhantomData; use std::rc::Rc; use std::sync::{Arc, Mutex}; /// Run the provided closure with a `MockClock` that starts at the current time. pub(crate) fn mock<F, R>(f: F) -> R where ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
8546ff826db8dba1e39b4119ad909fb6cab2492a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/time/tests/mock_clock.rs
1
60
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:2
_pd: PhantomData<Rc<()>>, } #[derive(Debug)] struct MockNow { inner: Inner, } #[derive(Debug)] struct MockPark { inner: Inner, _pd: PhantomData<Rc<()>>, } #[derive(Debug)] struct MockUnpark { inner: Inner, } #[derive(Debug)] struct State { clock: Clock, unparked: bool, park_for: Option<D...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
8546ff826db8dba1e39b4119ad909fb6cab2492a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/time/tests/mock_clock.rs
41
100
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:3
self.clock.enter(|| { let park = self.time.mock_park(); let timer = Driver::new(park, self.clock.clone()); let handle = timer.handle(); let _e = driver::set_default(&handle); let time = self.time.clone(); let mut handle = Handle::new(timer, time,...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
8546ff826db8dba1e39b4119ad909fb6cab2492a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/time/tests/mock_clock.rs
81
140
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:4
while Instant::now() < end { self.turn_for(end - Instant::now()); } } /// Returns the total amount of time the time has been advanced. pub(crate) fn advanced(&self) -> Duration { self.clock.advanced() } /// Get the currently mocked time pub(crate) fn now(&mut self) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
8546ff826db8dba1e39b4119ad909fb6cab2492a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/time/tests/mock_clock.rs
121
180
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:5
MockPark { inner, _pd: PhantomData, } } pub(crate) fn now(&self) -> Instant { Instant::now() } } impl State {} impl Park for MockPark { type Unpark = MockUnpark; type Error = (); fn unpark(&self) -> Self::Unpark { let inner = self.inner.clone()...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
8546ff826db8dba1e39b4119ad909fb6cab2492a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/time/tests/mock_clock.rs
161
211
tokio-rs/tokio:tokio/src/time/tests/mock_clock.rs:1
use crate::runtime::{Park, Unpark}; use crate::time::driver::{self, Driver}; use crate::time::{Clock, Duration, Instant}; use std::marker::PhantomData; use std::rc::Rc; use std::sync::{Arc, Mutex}; /// Run the provided closure with a `MockClock` that starts at the current time. pub(crate) fn mock<F, R>(f: F) -> R whe...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mock_clock.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/tests/mock_clock.rs
1
60
tokio-rs/tokio:tokio/src/time/tests/mod.rs:1
mod test_sleep; use crate::time::{self, Instant}; use std::time::Duration; fn assert_send<T: Send>() {} fn assert_sync<T: Sync>() {} #[test] fn registration_is_send_and_sync() { use crate::time::Sleep; assert_send::<Sleep>(); assert_sync::<Sleep>(); } #[test] #[should_panic] fn sleep_is_eager() { l...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mod.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/tests/mod.rs
1
22
tokio-rs/tokio:tokio/src/time/tests/mod.rs:1
mod test_sleep; use crate::time::{self, Instant}; use std::time::Duration; fn assert_send<T: Send>() {} fn assert_sync<T: Sync>() {} #[test] fn registration_is_send_and_sync() { use crate::time::sleep::Sleep; assert_send::<Sleep>(); assert_sync::<Sleep>(); } #[test] #[should_panic] fn sleep_is_eager() ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mod.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/tests/mod.rs
1
22
tokio-rs/tokio:tokio/src/time/tests/mod.rs:1
mod test_delay; use crate::time::{self, Instant}; use std::time::Duration; fn assert_send<T: Send>() {} fn assert_sync<T: Sync>() {} #[test] fn registration_is_send_and_sync() { use crate::time::delay::Delay; assert_send::<Delay>(); assert_sync::<Delay>(); } #[test] #[should_panic] fn delay_is_eager() ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mod.rs
MIT
fcdf9345bf19e9a1e1664f01713f9eba54da27c5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcdf9345bf19e9a1e1664f01713f9eba54da27c5/tokio/src/time/tests/mod.rs
1
22
tokio-rs/tokio:tokio/src/time/tests/mod.rs:1
mod test_delay; use crate::time::{self, Instant}; use std::time::Duration; fn assert_send<T: Send>() {} fn assert_sync<T: Sync>() {} #[test] fn registration_is_send_and_sync() { use crate::time::driver::Registration; assert_send::<Registration>(); assert_sync::<Registration>(); } #[test] #[should_panic...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mod.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/tests/mod.rs
1
22
tokio-rs/tokio:tokio/src/time/tests/mod.rs:1
mod test_delay; use crate::time::{self, Instant}; use std::time::Duration; fn assert_send<T: Send>() {} fn assert_sync<T: Sync>() {} #[test] fn registration_is_send_and_sync() { use crate::time::driver::Registration; assert_send::<Registration>(); assert_sync::<Registration>(); } #[test] #[should_panic...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mod.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/mod.rs
1
22
tokio-rs/tokio:tokio/src/time/tests/mod.rs:1
mod mock_clock; mod test_delay; mod test_queue; use crate::time::{self, Instant}; use std::time::Duration; fn assert_send<T: Send>() {} fn assert_sync<T: Sync>() {} #[test] fn registration_is_send_and_sync() { use crate::time::driver::Registration; assert_send::<Registration>(); assert_sync::<Registrati...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/mod.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/mod.rs
1
24
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:1
use crate::park::{Park, Unpark}; use crate::time::driver::{Driver, Entry, Handle}; use crate::time::Clock; use crate::time::{Duration, Instant}; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use std::sync::Arc; macro_rules! poll { ($e:expr) => { $e.enter(|cx, e| e.po...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
1
60
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:2
} #[test] fn delayed_delay_level_0() { let (mut driver, clock, handle) = setup(); let start = clock.now(); for &i in &[1, 10, 60] { // Create a `Delay` that elapses in the future let mut e = task::spawn(delay_until(&handle, start + ms(i))); // The delay has not elapsed. as...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
41
100
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:3
#[test] fn delayed_delay_wrapping_level_0() { let (mut driver, clock, handle) = setup(); let start = clock.now(); assert_ok!(driver.park_timeout(ms(5))); assert_eq!(clock.now() - start, ms(5)); let mut e = task::spawn(delay_until(&handle, clock.now() + ms(60))); assert_pending!(poll!(e)); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
81
140
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:4
assert_ok!(driver.park()); assert_eq!(clock.now() - start, ms(64)); assert_ready_ok!(poll!(e1)); assert_pending!(poll!(e2)); assert_ok!(driver.park()); assert_eq!(clock.now() - start, ms(65)); assert_ready_ok!(poll!(e1)); } #[test] fn delay_with_deadline_in_past() { let (mut driver, cloc...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
121
180
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:5
assert_pending!(poll!(e)); // Turn the timer, this will wake up to cascade the timer down. assert_ok!(driver.park_timeout(ms(1000))); assert_eq!(clock.now() - start, ms(192)); // The delay has not elapsed. assert_pending!(poll!(e)); // Turn the timer again assert_ok!(driver.park_timeout(m...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
161
220
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:6
assert_eq!(clock.now() - start, ms(234)); // The delay has elapsed. assert_ready_ok!(poll!(e)); } #[test] fn concurrently_set_two_timers_second_one_shorter() { let (mut driver, clock, handle) = setup(); let start = clock.now(); let mut e1 = task::spawn(delay_until(&handle, clock.now() + ms(500)))...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
201
260
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:7
} #[test] fn short_delay() { let (mut driver, clock, handle) = setup(); let start = clock.now(); // Create a `Delay` that elapses in the future let mut e = task::spawn(delay_until(&handle, clock.now() + ms(1))); // The delay has not elapsed. assert_pending!(poll!(e)); // Turn the timer, ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
241
300
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:8
assert_eq!(clock.now() - start, ms(elapsed)); assert_pending!(poll!(e)); } assert_ok!(driver.park()); assert_eq!(clock.now() - start, ms(MIN_5)); // The delay has elapsed. assert_ready_ok!(poll!(e)); } #[test] fn very_long_delay() { const MO_5: u64 = 5 * 30 * 24 * 60 * 60 * 1000; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
281
340
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:9
assert_ok!(driver.park()); // The time has advanced to the point of the delay elapsing. assert_eq!(clock.now() - start, ms(MO_5)); // The delay has elapsed. assert_ready_ok!(poll!(e)); } #[test] fn unpark_is_delayed() { // A special park that will take much longer than the requested duration ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
321
380
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:10
let clock = Clock::new(); clock.pause(); let start = clock.now(); let mut driver = Driver::new(MockPark(clock.clone()), clock.clone()); let handle = driver.handle(); let mut e1 = task::spawn(delay_until(&handle, clock.now() + ms(100))); let mut e2 = task::spawn(delay_until(&handle, clock.now() ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
361
420
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:11
assert_eq!(clock.now() - start, ms(YR_5) + ms(1)); assert_ready_ok!(poll!(e)); } fn setup() -> (Driver<MockPark>, Clock, Handle) { let clock = Clock::new(); clock.pause(); let driver = Driver::new(MockPark(clock.clone()), clock.clone()); let handle = driver.handle(); (driver, clock, handle) }...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/time/tests/test_delay.rs
401
449
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:9
assert_ok!(driver.park()); // The time has advanced to the point of the delay elapsing. assert_eq!(clock.now() - start, ms(MO_5)); // The delay has elapsed. assert_ready_ok!(poll!(e)); } #[test] fn unpark_is_delayed() { // A special park that will take much longer than the requested duration ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
9943acda81e19563c9f35ad2426e473732760e75
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9943acda81e19563c9f35ad2426e473732760e75/tokio/src/time/tests/test_delay.rs
321
380
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:10
clock.pause(); let start = clock.now(); let mut driver = Driver::new(MockPark(clock.clone()), clock.clone()); let handle = driver.handle(); let mut e1 = task::spawn(delay_until(&handle, clock.now() + ms(100))); let mut e2 = task::spawn(delay_until(&handle, clock.now() + ms(101))); let mut e3 = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
9943acda81e19563c9f35ad2426e473732760e75
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9943acda81e19563c9f35ad2426e473732760e75/tokio/src/time/tests/test_delay.rs
361
420
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:11
assert_ready_ok!(poll!(e)); } fn setup() -> (Driver<MockPark>, Clock, Handle) { let clock = Clock::new(); clock.pause(); let driver = Driver::new(MockPark(clock.clone()), clock.clone()); let handle = driver.handle(); (driver, clock, handle) } fn delay_until(handle: &Handle, when: Instant) -> Arc<...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
9943acda81e19563c9f35ad2426e473732760e75
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9943acda81e19563c9f35ad2426e473732760e75/tokio/src/time/tests/test_delay.rs
401
445
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:1
#![warn(rust_2018_idioms)] use crate::park::{Park, Unpark}; use crate::time::driver::{Driver, Entry, Handle}; use crate::time::Clock; use crate::time::{Duration, Instant}; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use std::sync::Arc; macro_rules! poll { ($e:expr) => { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
1
60
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:2
// The time has not advanced. The `turn` completed immediately. assert_eq!(clock.now() - start, ms(1000)); } #[test] fn delayed_delay_level_0() { let (mut driver, clock, handle) = setup(); let start = clock.now(); for &i in &[1, 10, 60] { // Create a `Delay` that elapses in the future ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
41
100
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:3
} } #[test] fn delayed_delay_wrapping_level_0() { let (mut driver, clock, handle) = setup(); let start = clock.now(); assert_ok!(driver.park_timeout(ms(5))); assert_eq!(clock.now() - start, ms(5)); let mut e = task::spawn(delay_until(&handle, clock.now() + ms(60))); assert_pending!(poll!(e))...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
81
140
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:4
// This should result in s1 firing assert_ok!(driver.park()); assert_eq!(clock.now() - start, ms(64)); assert_ready_ok!(poll!(e1)); assert_pending!(poll!(e2)); assert_ok!(driver.park()); assert_eq!(clock.now() - start, ms(65)); assert_ready_ok!(poll!(e1)); } #[test] fn delay_with_deadlin...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
121
180
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:5
// The delay has not elapsed. assert_pending!(poll!(e)); // Turn the timer, this will wake up to cascade the timer down. assert_ok!(driver.park_timeout(ms(1000))); assert_eq!(clock.now() - start, ms(192)); // The delay has not elapsed. assert_pending!(poll!(e)); // Turn the timer again ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
161
220
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:6
// Turn the timer again assert_ok!(driver.park_timeout(ms(1000))); assert_eq!(clock.now() - start, ms(234)); // The delay has elapsed. assert_ready_ok!(poll!(e)); } #[test] fn concurrently_set_two_timers_second_one_shorter() { let (mut driver, clock, handle) = setup(); let start = clock.now();...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
201
260
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:7
assert_ready_ok!(poll!(e1)); } #[test] fn short_delay() { let (mut driver, clock, handle) = setup(); let start = clock.now(); // Create a `Delay` that elapses in the future let mut e = task::spawn(delay_until(&handle, clock.now() + ms(1))); // The delay has not elapsed. assert_pending!(poll!(...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
241
300
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:8
for &elapsed in cascades { assert_ok!(driver.park()); assert_eq!(clock.now() - start, ms(elapsed)); assert_pending!(poll!(e)); } assert_ok!(driver.park()); assert_eq!(clock.now() - start, ms(MIN_5)); // The delay has elapsed. assert_ready_ok!(poll!(e)); } #[test] fn very_...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
281
340
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:9
// Turn the timer, but not enough time will go by. assert_ok!(driver.park()); // The time has advanced to the point of the delay elapsing. assert_eq!(clock.now() - start, ms(MO_5)); // The delay has elapsed. assert_ready_ok!(poll!(e)); } #[test] fn unpark_is_delayed() { // A special park that...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
321
380
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:11
assert_eq!(clock.now() - start, ms(YR_5) + ms(1)); assert_ready_ok!(poll!(e)); } fn setup() -> (Driver<MockPark>, Clock, Handle) { let clock = Clock::new(); clock.pause(); let driver = Driver::new(MockPark(clock.clone()), clock.clone()); let handle = driver.handle(); (driver, clock, handle) }...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
57ba37c97854d32e691ea68006c8d69d58c79b23
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57ba37c97854d32e691ea68006c8d69d58c79b23/tokio/src/time/tests/test_delay.rs
401
447
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:1
#![warn(rust_2018_idioms)] use crate::park::{Park, Unpark}; use crate::time::driver::{Driver, Entry, Handle}; use crate::time::Clock; use crate::time::{Duration, Instant}; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use std::sync::Arc; macro_rules! poll { ($e:expr) => { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
1
60
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:2
// Create a `Delay` that elapses in the future let mut e = task::spawn(delay_until(&handle, start + ms(i))); // The delay has not elapsed. assert_pending!(poll!(e)); assert_ok!(driver.park()); assert_eq!(clock.advanced(), ms(i)); assert_ready_ok!(poll!(e)); } } #[...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
41
100
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:3
let mut e = task::spawn(delay_until(&handle, clock.now() + ms(60))); assert_pending!(poll!(e)); assert_ok!(driver.park()); assert_eq!(clock.advanced(), ms(64)); assert_pending!(poll!(e)); assert_ok!(driver.park()); assert_eq!(clock.advanced(), ms(65)); assert_ready_ok!(poll!(e)); } #[te...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
81
140
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:4
} #[test] fn delay_with_deadline_in_past() { let (mut driver, clock, handle) = setup(); // Create `Delay` that elapsed immediately. let mut e = task::spawn(delay_until(&handle, clock.now() - ms(100))); // Even though the delay expires in the past, it is not ready yet // because the timer must obs...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
121
180
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:5
// The delay has elapsed. assert_ready_ok!(poll!(e)); let (mut driver, clock, handle) = setup(); // Create a `Delay` that elapses in the future let mut e = task::spawn(delay_until(&handle, clock.now() + ms(234))); // The delay has not elapsed. assert_pending!(poll!(e)); // Turn the timer...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
161
220
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:6
// The delay has not elapsed assert_pending!(poll!(e1)); assert_pending!(poll!(e2)); // Delay until a cascade assert_ok!(driver.park()); assert_eq!(clock.advanced(), ms(192)); // Delay until the second timer. assert_ok!(driver.park()); assert_eq!(clock.advanced(), ms(200)); // The...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
201
260
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:7
// The delay has elapsed. assert_ready_ok!(poll!(e)); // The time has advanced to the point of the delay elapsing. assert_eq!(clock.advanced(), ms(1)); } #[test] fn sorta_long_delay_until() { const MIN_5: u64 = 5 * 60 * 1000; let (mut driver, clock, handle) = setup(); // Create a `Delay` tha...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
241
300
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:8
let (mut driver, clock, handle) = setup(); // Create a `Delay` that elapses in the future let mut e = task::spawn(delay_until(&handle, clock.now() + ms(MO_5))); // The delay has not elapsed. assert_pending!(poll!(e)); let cascades = &[ 12_884_901_888, 12_952_010_752, 12_95...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
281
340
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:9
type Unpark = MockUnpark; type Error = (); fn unpark(&self) -> Self::Unpark { MockUnpark } fn park(&mut self) -> Result<(), Self::Error> { panic!("parking forever"); } fn park_timeout(&mut self, duration: Duration) -> Result<(), Self::Error> { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
321
380
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:10
assert_ready_ok!(poll!(e3)); } #[test] fn set_timeout_at_deadline_greater_than_max_timer() { const YR_1: u64 = 365 * 24 * 60 * 60 * 1000; const YR_5: u64 = 5 * YR_1; let (mut driver, clock, handle) = setup(); for _ in 0..5 { assert_ok!(driver.park_timeout(ms(YR_1))); } let mut e = ta...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
361
420
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:11
type Unpark = MockUnpark; type Error = (); fn unpark(&self) -> Self::Unpark { MockUnpark } fn park(&mut self) -> Result<(), Self::Error> { panic!("parking forever"); } fn park_timeout(&mut self, duration: Duration) -> Result<(), Self::Error> { self.0.advance(duration);...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
f0006006ed9938115011c42f26cff16842eb534f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/time/tests/test_delay.rs
401
424
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:1
#![warn(rust_2018_idioms)] use crate::time::tests::mock_clock::mock; use crate::time::{delay_until, Duration, Instant}; use tokio_test::task; use tokio_test::{assert_pending, assert_ready}; #[test] fn immediate_delay() { mock(|clock| { // Create `Delay` that elapsed immediately. let mut fut = task...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
1
60
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:2
} #[test] fn sub_ms_delayed_delay() { mock(|clock| { for _ in 0..5 { let deadline = clock.now() + Duration::from_millis(1) + Duration::new(0, 1); let mut fut = task::spawn(delay_until(deadline)); assert_pending!(fut.poll()); clock.turn(); asser...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
41
100
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:3
}); } #[test] fn timer_wrapping_with_higher_levels() { mock(|clock| { // Set delay to hit level 1 let mut s1 = task::spawn(delay_until(clock.now() + ms(64))); assert_pending!(s1.poll()); // Turn a bit clock.turn_for(ms(5)); // Set timeout such that it will hit leve...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
81
140
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:4
// Turn the timer, it runs for the elapsed time clock.turn_for(ms(1000)); // The time has not advanced. The `turn` completed immediately. assert_eq!(clock.advanced(), ms(1000)); }); } #[test] fn delayed_delay_level_1() { mock(|clock| { // Create a `Delay` that elapses in the fu...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
121
180
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:5
// Turn the timer with a smaller timeout than the cascade. clock.turn_for(ms(100)); assert_eq!(clock.advanced(), ms(100)); assert_pending!(fut.poll()); // Turn the timer, this will wake up to cascade the timer down. clock.turn_for(ms(1000)); assert_eq!(clock.advanced(),...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
161
220
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:6
assert_pending!(fut2.poll()); // Delay until a cascade clock.turn(); assert_eq!(clock.advanced(), ms(192)); // Delay until the second timer. clock.turn(); assert_eq!(clock.advanced(), ms(200)); // The shorter delay fires assert_ready!(fut2.poll()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
201
260
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:7
assert_ready!(fut.poll()); // The time has advanced to the point of the delay elapsing. assert_eq!(clock.advanced(), ms(1)); }) } #[test] fn sorta_long_delay_until() { const MIN_5: u64 = 5 * 60 * 1000; mock(|clock| { // Create a `Delay` that elapses in the future let mut f...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
241
300
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:8
// Create a `Delay` that elapses in the future let mut fut = task::spawn(delay_until(clock.now() + ms(MO_5))); // The delay has not elapsed. assert_pending!(fut.poll()); let cascades = &[ 12_884_901_888, 12_952_010_752, 12_959_875_072, 12...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
281
340
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:9
assert_pending!(fut.poll()); clock.turn_for(ms(0)); // boom let _ = fut.poll(); }) } #[test] fn unpark_is_delayed() { mock(|clock| { let mut fut1 = task::spawn(delay_until(clock.now() + ms(100))); let mut fut2 = task::spawn(delay_until(clock.now() + ms(101))); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
321
380
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:10
let mut fut = task::spawn(delay_until(clock.now() + ms(1))); assert_pending!(fut.poll()); clock.turn_for(ms(1000)); assert_eq!(clock.advanced(), ms(YR_5) + ms(1)); assert_ready!(fut.poll()); }); } #[test] fn reset_future_delay_before_fire() { mock(|clock| { let mut fut...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
361
420
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:11
clock.turn(); assert_eq!(clock.advanced(), ms(64)); assert_pending!(fut.poll()); clock.turn(); assert_eq!(clock.advanced(), ms(80)); assert_ready!(fut.poll()); }); } #[test] fn reset_past_delay_before_fire() { mock(|clock| { let mut fut = task::spawn(delay_unt...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
401
460
tokio-rs/tokio:tokio/src/time/tests/test_delay.rs:12
assert_pending!(fut.poll()); clock.turn_for(ms(1000)); assert_eq!(clock.advanced(), ms(64)); clock.turn(); assert_eq!(clock.advanced(), ms(100)); assert_ready!(fut.poll()); fut.reset(clock.now() + ms(10)); assert_pending!(fut.poll()); clock.turn_for(m...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/time/tests/test_delay.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/tests/test_delay.rs
441
463