Lines Matching full:sleep
13 /// No work is performed while awaiting on the sleep future to complete. `Sleep`
21 /// Canceling a sleep instance is done by dropping the returned future. No additional
38 /// See the documentation for the [`Sleep`] type for more examples.
48 /// Tokio runtime. That is why `rt.block_on(sleep(...))` will panic,
50 /// Whereas `rt.block_on(async {sleep(...).await})` doesn't panic.
55 /// [`Sleep`]: struct@crate::time::Sleep
62 pub fn sleep_until(deadline: Instant) -> Sleep { in sleep_until() argument
63 Sleep::new_timeout(deadline, trace::caller_location()) in sleep_until()
69 /// analog to `std::thread::sleep`.
71 /// No work is performed while awaiting on the sleep future to complete. `Sleep`
79 /// The maximum duration for a sleep is 68719476734 milliseconds (approximately 2.2 years).
83 /// Canceling a sleep instance is done by dropping the returned future. No additional
91 /// use tokio::time::{sleep, Duration};
95 /// sleep(Duration::from_millis(100)).await;
100 /// See the documentation for the [`Sleep`] type for more examples.
110 /// Tokio runtime. That is why `rt.block_on(sleep(...))` will panic,
112 /// Whereas `rt.block_on(async {sleep(...).await})` doesn't panic.
117 /// [`Sleep`]: struct@crate::time::Sleep
125 pub fn sleep(duration: Duration) -> Sleep { in sleep() function
129 Some(deadline) => Sleep::new_timeout(deadline, location), in sleep()
130 None => Sleep::new_timeout(Instant::far_future(), location), in sleep()
135 /// Future returned by [`sleep`](sleep) and [`sleep_until`](sleep_until).
146 /// use tokio::time::{sleep, Duration};
150 /// sleep(Duration::from_millis(100)).await;
155 /// Use with [`select!`]. Pinning the `Sleep` with [`tokio::pin!`] is
156 /// necessary when the same `Sleep` is selected on multiple times.
162 /// let sleep = time::sleep(Duration::from_millis(10));
163 /// tokio::pin!(sleep);
167 /// () = &mut sleep => {
169 /// sleep.as_mut().reset(Instant::now() + Duration::from_millis(50));
175 /// Use in a struct with boxing. By pinning the `Sleep` with a `Box`, the
176 /// `HasSleep` struct implements `Unpin`, even though `Sleep` does not.
181 /// use tokio::time::Sleep;
184 /// sleep: Pin<Box<Sleep>>,
191 /// self.sleep.as_mut().poll(cx)
201 /// use tokio::time::Sleep;
207 /// sleep: Sleep,
215 /// self.project().sleep.poll(cx)
227 pub struct Sleep {
230 // The link between the `Sleep` instance and the timer that drives it.
249 impl Sleep { implementation
255 ) -> Sleep { in new_timeout() argument
272 concrete_type = "Sleep", in new_timeout()
287 tracing::trace_span!("runtime.resource.async_op", source = "Sleep::new_timeout") in new_timeout()
305 Sleep { inner, entry } in new_timeout()
308 pub(crate) fn far_future(location: Option<&'static Location<'static>>) -> Sleep { in far_future() argument
317 /// Returns `true` if `Sleep` has elapsed.
319 /// A `Sleep` instance is elapsed when the requested duration has elapsed.
324 /// Resets the `Sleep` instance to a new deadline.
326 /// Calling this function allows changing the instant at which the `Sleep`
334 /// `Sleep` itself.
343 /// let sleep = tokio::time::sleep(Duration::from_millis(10));
344 /// tokio::pin!(sleep);
346 /// sleep.as_mut().reset(Instant::now() + Duration::from_millis(20));
357 /// Resets the `Sleep` instance to a new deadline without reregistering it
360 /// Calling this function allows changing the instant at which the `Sleep`
363 /// [`crate::time::Interval`] where we want to reset the internal [Sleep]
378 tracing::trace_span!("runtime.resource.async_op", source = "Sleep::reset"); in reset_inner()
429 impl Future for Sleep { implementation
435 // sleep instances have been scheduled.