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/handle.rs:2
/// This function panics if there is no current timer set. /// /// It can be triggered when `Builder::enable_time()` or /// `Builder::enable_all()` are not included in the builder. /// /// It can also panic whenever a timer is created outside of a /// Tokio runtime. That ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/handle.rs
41
88
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::loom::sync::{Arc, Mutex}; use crate::time::driver::ClockTime; use std::fmt; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { time_source: ClockTime, inner: Arc<Mutex<super::Inner>>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
fdde5583f853655fec57c44928b7d5f01621b754
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdde5583f853655fec57c44928b7d5f01621b754/tokio/src/time/driver/handle.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/handle.rs:2
/// It can also panic whenever a timer is created outside of a /// Tokio runtime. That is why `rt.block_on(delay_for(...))` will panic, /// since the function is executed outside of the runtime. /// Whereas `rt.block_on(async {delay_for(...).await})` doesn't panic. /// And this is becaus...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
fdde5583f853655fec57c44928b7d5f01621b754
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdde5583f853655fec57c44928b7d5f01621b754/tokio/src/time/driver/handle.rs
41
83
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::loom::sync::{Arc, Mutex}; use crate::time::driver::ClockTime; use std::fmt; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { time_source: ClockTime, inner: Arc<Mutex<super::Inner>>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
de33ee85ce61377b316b630e4355d419cc4abcb7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/de33ee85ce61377b316b630e4355d419cc4abcb7/tokio/src/time/driver/handle.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/handle.rs:2
/// It can also panic whenever a timer is created outside of a /// Tokio runtime. That is why `rt.block_on(delay_for(...))` will panic, /// since the function is executed outside of the runtime. /// Whereas `rt.block_on(async {delay_for(...).await})` doesn't panic. /// And this is becaus...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
de33ee85ce61377b316b630e4355d419cc4abcb7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/de33ee85ce61377b316b630e4355d419cc4abcb7/tokio/src/time/driver/handle.rs
41
84
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::loom::sync::{Arc, Mutex}; use crate::time::driver::ClockTime; use std::fmt; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { time_source: ClockTime, inner: Arc<Mutex<super::Inner>>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/handle.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/handle.rs:2
/// It can also panic whenever a timer is created ouClockTimeide of a /// Tokio runtime. That is why `rt.block_on(delay_for(...))` will panic, /// since the function is executed ouClockTimeide of the runtime. /// Whereas `rt.block_on(async {delay_for(...).await})` doesn't panic. /// And ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/handle.rs
41
84
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::time::driver::Inner; use std::fmt; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn new(inner: Weak<Inner>) -> Self { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/handle.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/handle.rs:2
pub(crate) fn current() -> Self { crate::runtime::context::time_handle() .expect("there is no timer running, must be called from the context of Tokio runtime") } } } cfg_not_rt! { impl Handle { /// Tries to get a handle to the current timer. /// /// #...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/handle.rs
41
77
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::time::driver::Inner; use std::fmt; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn new(inner: Weak<Inner>) -> Self { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/time/driver/handle.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/handle.rs:2
pub(crate) fn current() -> Self { crate::runtime::context::time_handle() .expect("there is no timer running, must be called from the context of Tokio runtime") } } } cfg_not_rt_core! { impl Handle { /// Tries to get a handle to the current timer. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/time/driver/handle.rs
41
77
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::runtime::context; use crate::time::driver::Inner; use std::fmt; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn new(i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/time/driver/handle.rs
1
49
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::runtime::context; use crate::time::driver::Inner; use std::fmt; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn new(i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
6260ed907bff17abe2b889c2f87e7086284ddf05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6260ed907bff17abe2b889c2f87e7086284ddf05/tokio/src/time/driver/handle.rs
1
49
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::runtime::context; use crate::time::driver::Inner; use std::fmt; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn new(i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
9eca96aa214cb8e2fd695cbed179f93826b3ef46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9eca96aa214cb8e2fd695cbed179f93826b3ef46/tokio/src/time/driver/handle.rs
1
38
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::runtime::context; use crate::time::driver::Inner; use std::fmt; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } impl Handle { /// Creates a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn new(i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/time/driver/handle.rs
1
37
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::runtime::context; use crate::time::driver::Inner; use std::fmt; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } impl Handle { /// Create a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn new(in...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
45da5f3510a61599c89dc458ecc859f13a81e255
github
async-runtime
https://github.com/tokio-rs/tokio/blob/45da5f3510a61599c89dc458ecc859f13a81e255/tokio/src/time/driver/handle.rs
1
37
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::runtime::context; use crate::time::driver::Inner; use std::fmt; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } impl Handle { /// Create a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn new(in...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
67bf9c36f347031ca05872d102a7f9abc8b465f0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67bf9c36f347031ca05872d102a7f9abc8b465f0/tokio/src/time/driver/handle.rs
1
37
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::time::driver::Inner; use std::cell::RefCell; use std::fmt; use std::marker::PhantomData; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Clone)] pub(crate) struct Handle { inner: Weak<Inner>, } thread_local! { /// Tracks the timer for the current execution context. stat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
dbcd1f9a0964c64d5aa335649eabea281ac59574
github
async-runtime
https://github.com/tokio-rs/tokio/blob/dbcd1f9a0964c64d5aa335649eabea281ac59574/tokio/src/time/driver/handle.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/handle.rs:2
let mut current = current.borrow_mut(); let prev = current.take(); *current = Some(handle.clone()); DefaultGuard { prev, _lifetime: PhantomData, } }) } impl Handle { /// Create a new timer `Handle` from a shared `Inner` timer state. pub(crate) fn ne...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
dbcd1f9a0964c64d5aa335649eabea281ac59574
github
async-runtime
https://github.com/tokio-rs/tokio/blob/dbcd1f9a0964c64d5aa335649eabea281ac59574/tokio/src/time/driver/handle.rs
41
81
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::time::driver::Inner; use std::cell::RefCell; use std::fmt; use std::marker::PhantomData; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Debug, Clone)] pub(crate) struct Handle { inner: Option<HandlePriv>, } /// Like `Handle` but never `None`. #[derive(Clone)] pub(crate) struct...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/driver/handle.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/handle.rs:2
/// /// # Panics /// /// This function panics if there already is a default timer set. pub(crate) fn set_default(handle: &Handle) -> DefaultGuard<'_> { CURRENT_TIMER.with(|current| { let mut current = current.borrow_mut(); let prev = current.take(); let handle = handle .as_priv(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/driver/handle.rs
41
100
tokio-rs/tokio:tokio/src/time/driver/handle.rs:3
/// Try to get a handle to the current timer. /// /// # Panics /// /// This function panics if there is no current timer set. pub(crate) fn current() -> Self { CURRENT_TIMER.with(|current| match *current.borrow() { Some(ref handle) => handle.clone(), None => panic!("n...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
3e643c7b81736a4c2b11387a6f71aba99450270b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e643c7b81736a4c2b11387a6f71aba99450270b/tokio/src/time/driver/handle.rs
81
108
tokio-rs/tokio:tokio/src/time/driver/handle.rs:1
use crate::time::driver::Inner; use crate::time::Error; use std::cell::RefCell; use std::fmt; use std::marker::PhantomData; use std::sync::{Arc, Weak}; /// Handle to time driver instance. #[derive(Debug, Clone)] pub(crate) struct Handle { inner: Option<HandlePriv>, } /// Like `Handle` but never `None`. #[derive(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/driver/handle.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/handle.rs:2
///Sets handle to default timer, returning guard that unsets it on drop. /// /// # Panics /// /// This function panics if there already is a default timer set. pub(crate) fn set_default(handle: &Handle) -> DefaultGuard<'_> { CURRENT_TIMER.with(|current| { let mut current = current.borrow_mut(); let ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/driver/handle.rs
41
100
tokio-rs/tokio:tokio/src/time/driver/handle.rs:3
impl HandlePriv { /// Try to get a handle to the current timer. /// /// Returns `Err` if no handle is found. pub(crate) fn try_current() -> Result<HandlePriv, Error> { CURRENT_TIMER.with(|current| match *current.borrow() { Some(ref handle) => Ok(handle.clone()), None => E...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/handle.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/time/driver/handle.rs
81
108
tokio-rs/tokio:tokio/src/time/driver/mod.rs:1
// Currently, rust warns when an unsafe fn contains an unsafe {} block. However, // in the future, this will change to the reverse. For now, suppress this // warning and generally stick with being explicit about unsafety. #![allow(unused_unsafe)] #![cfg_attr(not(feature = "rt"), allow(dead_code))] //! Time driver. mo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/mod.rs:3
/// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver<P: Park + 'static> { /// Timing backend in use. time_source: ClockTime, /// Shared state. handle: Handle, /// Parker to delegate to. park: P, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
81
140
tokio-rs/tokio:tokio/src/time/driver/mod.rs:4
// Round up to the end of a ms self.instant_to_tick(t + Duration::from_nanos(999_999)) } pub(self) fn instant_to_tick(&self, t: Instant) -> u64 { // round up let dur: Duration = t .checked_duration_since(self.start_time) .unwrap_or_else(|| Duration::from_secs(0))...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
121
180
tokio-rs/tokio:tokio/src/time/driver/mod.rs:5
/// The earliest time at which we promise to wake up without unparking. next_wake: Option<NonZeroU64>, /// Timer wheel. wheel: wheel::Wheel, /// Unparker that can be used to wake the time driver. unpark: Box<dyn Unpark>, } // ===== impl Driver ===== impl<P> Driver<P> where P: Park + 'static,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
161
220
tokio-rs/tokio:tokio/src/time/driver/mod.rs:6
pub(crate) fn handle(&self) -> Handle { self.handle.clone() } fn park_internal(&mut self, limit: Option<Duration>) -> Result<(), P::Error> { let mut lock = self.handle.get().state.lock(); assert!(!self.handle.is_shutdown()); let next_wake = lock.wheel.next_expiration_time(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
201
260
tokio-rs/tokio:tokio/src/time/driver/mod.rs:7
} // Process pending timers after waking up self.handle.process(); Ok(()) } cfg_test_util! { fn park_timeout(&mut self, duration: Duration) -> Result<(), P::Error> { let clock = &self.time_source.clock; if clock.is_paused() { self.park....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
241
300
tokio-rs/tokio:tokio/src/time/driver/mod.rs:8
} impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self) { let now = self.time_source().now(); self.process_at_time(now) } pub(self) fn process_at_time(&self, mut now: u64) { let mut waker_list: [Option<Waker>; 32] = Default::d...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
281
340
tokio-rs/tokio:tokio/src/time/driver/mod.rs:9
waker.take().unwrap().wake(); } waker_idx = 0; lock = self.get().lock(); } } } // Update the elapsed cache lock.elapsed = lock.wheel.elapsed(); lock.next_wake = lock .wheel ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
321
380
tokio-rs/tokio:tokio/src/time/driver/mod.rs:10
} entry.as_ref().handle().fire(Ok(())); } } /// Removes and re-adds an entry to the driver. /// /// SAFETY: The timer must be either unregistered, or registered with this /// driver. No other threads are allowed to concurrently manipulate the /// timer at all (the current t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
361
420
tokio-rs/tokio:tokio/src/time/driver/mod.rs:11
lock.unpark.unpark(); } None } Err((entry, super::error::InsertError::Elapsed)) => unsafe { entry.fire(Ok(())) }, } } // Must release lock before ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
401
460
tokio-rs/tokio:tokio/src/time/driver/mod.rs:12
} fn shutdown(&mut self) { if self.handle.is_shutdown() { return; } self.handle.get().is_shutdown.store(true, Ordering::SeqCst); // Advance time forward to the end of time. self.handle.process_at_time(u64::MAX); self.park.shutdown(); } } impl<P> ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
441
500
tokio-rs/tokio:tokio/src/time/driver/mod.rs:13
} } } impl<P: Park + 'static> Unpark for TimerUnpark<P> { fn unpark(&self) { #[cfg(feature = "test-util")] self.did_wake.store(true, Ordering::SeqCst); self.inner.unpark(); } } // ===== impl Inner ===== impl Inner { pub(self) fn new(time_source: ClockTime, unpark: Box<dyn Unp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0826f763e04c5d86050c35bf7af9055e095263d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0826f763e04c5d86050c35bf7af9055e095263d3/tokio/src/time/driver/mod.rs
481
528
tokio-rs/tokio:tokio/src/time/driver/mod.rs:3
/// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver<P: Park + 'static> { /// Timing backend in use. time_source: ClockTime, /// Shared state. handle: Handle, /// Parker to delegate to. park: P, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/mod.rs
81
140
tokio-rs/tokio:tokio/src/time/driver/mod.rs:4
// Round up to the end of a ms self.instant_to_tick(t + Duration::from_nanos(999_999)) } pub(self) fn instant_to_tick(&self, t: Instant) -> u64 { // round up let dur: Duration = t .checked_duration_since(self.start_time) .unwrap_or_else(|| Duration::from_secs(0))...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/time/driver/mod.rs
121
180
tokio-rs/tokio:tokio/src/time/driver/mod.rs:1
// Currently, rust warns when an unsafe fn contains an unsafe {} block. However, // in the future, this will change to the reverse. For now, suppress this // warning and generally stick with being explicit about unsafety. #![allow(unused_unsafe)] #![cfg_attr(not(feature = "rt"), allow(dead_code))] //! Time driver mod...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
5ac32934b409f9c77510e41b0f10abe5e855cde5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5ac32934b409f9c77510e41b0f10abe5e855cde5/tokio/src/time/driver/mod.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/mod.rs:3
/// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver<P: Park + 'static> { /// Timing backend in use time_source: ClockTime, /// Shared state handle: Handle, /// Parker to delegate to park: P, //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
5ac32934b409f9c77510e41b0f10abe5e855cde5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5ac32934b409f9c77510e41b0f10abe5e855cde5/tokio/src/time/driver/mod.rs
81
140
tokio-rs/tokio:tokio/src/time/driver/mod.rs:4
// Round up to the end of a ms self.instant_to_tick(t + Duration::from_nanos(999_999)) } pub(self) fn instant_to_tick(&self, t: Instant) -> u64 { // round up let dur: Duration = t .checked_duration_since(self.start_time) .unwrap_or_else(|| Duration::from_secs(0))...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
5ac32934b409f9c77510e41b0f10abe5e855cde5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5ac32934b409f9c77510e41b0f10abe5e855cde5/tokio/src/time/driver/mod.rs
121
180
tokio-rs/tokio:tokio/src/time/driver/mod.rs:5
/// The earliest time at which we promise to wake up without unparking next_wake: Option<NonZeroU64>, /// Timer wheel wheel: wheel::Wheel, /// Unparker that can be used to wake the time driver unpark: Box<dyn Unpark>, } // ===== impl Driver ===== impl<P> Driver<P> where P: Park + 'static, { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
5ac32934b409f9c77510e41b0f10abe5e855cde5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5ac32934b409f9c77510e41b0f10abe5e855cde5/tokio/src/time/driver/mod.rs
161
220
tokio-rs/tokio:tokio/src/time/driver/mod.rs:7
} // Process pending timers after waking up self.handle.process(); Ok(()) } cfg_test_util! { fn park_timeout(&mut self, duration: Duration) -> Result<(), P::Error> { let clock = &self.time_source.clock; if clock.is_paused() { self.park....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
18779aa2e292c4c060a35c2882601373c36e7af0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/src/time/driver/mod.rs
241
300
tokio-rs/tokio:tokio/src/time/driver/mod.rs:8
} impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self) { let now = self.time_source().now(); self.process_at_time(now) } pub(self) fn process_at_time(&self, now: u64) { let mut waker_list: [Option<Waker>; 32] = Default::defau...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
18779aa2e292c4c060a35c2882601373c36e7af0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/src/time/driver/mod.rs
281
340
tokio-rs/tokio:tokio/src/time/driver/mod.rs:9
} // Update the elapsed cache lock.elapsed = lock.wheel.elapsed(); lock.next_wake = lock .wheel .poll_at() .map(|t| NonZeroU64::new(t).unwrap_or_else(|| NonZeroU64::new(1).unwrap())); drop(lock); for waker in waker_list[0..waker_idx].iter_mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
18779aa2e292c4c060a35c2882601373c36e7af0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/src/time/driver/mod.rs
321
380
tokio-rs/tokio:tokio/src/time/driver/mod.rs:10
/// SAFETY: The timer must be either unregistered, or registered with this /// driver. No other threads are allowed to concurrently manipulate the /// timer at all (the current thread should hold an exclusive reference to /// the `TimerEntry`) pub(self) unsafe fn reregister(&self, new_tick: u64, entry: ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
18779aa2e292c4c060a35c2882601373c36e7af0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/src/time/driver/mod.rs
361
420
tokio-rs/tokio:tokio/src/time/driver/mod.rs:11
} } // Must release lock before invoking waker to avoid the risk of deadlock. }; // The timer was fired synchronously as a result of the reregistration. // Wake the waker; this is needed because we might reset _after_ a poll, // and otherwise the task won't be a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
18779aa2e292c4c060a35c2882601373c36e7af0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/src/time/driver/mod.rs
401
460
tokio-rs/tokio:tokio/src/time/driver/mod.rs:12
// Advance time forward to the end of time. self.handle.process_at_time(u64::MAX); self.park.shutdown(); } } impl<P> Drop for Driver<P> where P: Park + 'static, { fn drop(&mut self) { self.shutdown(); } } pub(crate) struct TimerUnpark<P: Park + 'static> { inner: P::Unpark...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
18779aa2e292c4c060a35c2882601373c36e7af0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/src/time/driver/mod.rs
441
500
tokio-rs/tokio:tokio/src/time/driver/mod.rs:13
self.inner.unpark(); } } // ===== impl Inner ===== impl Inner { pub(self) fn new(time_source: ClockTime, unpark: Box<dyn Unpark>) -> Self { Inner { state: Mutex::new(InnerState { time_source, elapsed: 0, next_wake: None, unpar...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
18779aa2e292c4c060a35c2882601373c36e7af0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/src/time/driver/mod.rs
481
520
tokio-rs/tokio:tokio/src/time/driver/mod.rs:3
/// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver<P: Park + 'static> { /// Timing backend in use time_source: ClockTime, /// Shared state handle: Handle, /// Parker to delegate to park: P, } /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
81
140
tokio-rs/tokio:tokio/src/time/driver/mod.rs:4
let ms = dur.as_millis(); ms.try_into().expect("Duration too far into the future") } pub(self) fn tick_to_duration(&self, t: u64) -> Duration { Duration::from_millis(t) } pub(self) fn now(&self) -> u64 { self.instant_to_tick(self.clock.now()) } } /// Timer state shared be...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
121
180
tokio-rs/tokio:tokio/src/time/driver/mod.rs:5
// ===== impl Driver ===== impl<P> Driver<P> where P: Park + 'static, { /// Creates a new `Driver` instance that uses `park` to block the current /// thread and `time_source` to get the current time and convert to ticks. /// /// Specifying the source of time is useful when testing. pub(crate) f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
161
220
tokio-rs/tokio:tokio/src/time/driver/mod.rs:6
let next_wake = lock.wheel.next_expiration_time(); lock.next_wake = next_wake.map(|t| NonZeroU64::new(t).unwrap_or_else(|| NonZeroU64::new(1).unwrap())); drop(lock); match next_wake { Some(when) => { let now = self.time_source.now(); // N...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
201
260
tokio-rs/tokio:tokio/src/time/driver/mod.rs:7
self.park.park()?; } } } // Process pending timers after waking up self.handle.process(); Ok(()) } } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self) { let now = self.time_source()....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
241
300
tokio-rs/tokio:tokio/src/time/driver/mod.rs:9
if entry.as_ref().might_be_registered() { lock.wheel.remove(entry); } entry.as_ref().handle().fire(Ok(())); } } /// Removes and re-adds an entry to the driver. /// /// SAFETY: The timer must be either unregistered, or registered with this /// driver....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
321
380
tokio-rs/tokio:tokio/src/time/driver/mod.rs:10
.unwrap_or(true) { lock.unpark.unpark(); } None } Err((entry, super::error::InsertError::Elapsed)) => unsafe { entry.fire(Ok(())) }, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
361
420
tokio-rs/tokio:tokio/src/time/driver/mod.rs:11
fn park_timeout(&mut self, duration: Duration) -> Result<(), Self::Error> { self.park_internal(Some(duration)) } fn shutdown(&mut self) { if self.handle.is_shutdown() { return; } self.handle.get().is_shutdown.store(true, Ordering::SeqCst); // Advance time f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
401
460
tokio-rs/tokio:tokio/src/time/driver/mod.rs:12
is_shutdown: AtomicBool::new(false), } } /// Locks the driver's inner structure pub(super) fn lock(&self) -> crate::loom::sync::MutexGuard<'_, InnerState> { self.state.lock() } // Check whether the driver has been shutdown pub(super) fn is_shutdown(&self) -> bool { self...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c39d9867bb989396bb02e74d87f2805969f43f03
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c39d9867bb989396bb02e74d87f2805969f43f03/tokio/src/time/driver/mod.rs
441
463
tokio-rs/tokio:tokio/src/time/driver/mod.rs:1
// Currently, rust warns when an unsafe fn contains an unsafe {} block. However, // in the future, this will change to the reverse. For now, suppress this // warning and generally stick with being explicit about unsafety. #![allow(unused_unsafe)] #![cfg_attr(not(feature = "rt"), allow(dead_code))] //! Time driver mod...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/mod.rs:3
/// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver<P: Park + 'static> { /// Timing backend in use time_source: ClockTime, /// Shared state inner: Handle, /// Parker to delegate to park: P, } /// A structure which handles convers...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
81
140
tokio-rs/tokio:tokio/src/time/driver/mod.rs:4
ms.try_into().expect("Duration too far into the future") } pub(self) fn tick_to_duration(&self, t: u64) -> Duration { Duration::from_millis(t) } pub(self) fn now(&self) -> u64 { self.instant_to_tick(self.clock.now()) } } /// Timer state shared between `Driver`, `Handle`, and `Regi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
121
180
tokio-rs/tokio:tokio/src/time/driver/mod.rs:5
/// Creates a new `Driver` instance that uses `park` to block the current /// thread and `time_source` to get the current time and convert to ticks. /// /// Specifying the source of time is useful when testing. pub(crate) fn new(park: P, clock: Clock) -> Driver<P> { let time_source = ClockTime::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
161
220
tokio-rs/tokio:tokio/src/time/driver/mod.rs:6
Some(when) => { let now = self.time_source.now(); // Note that we effectively round up to 1ms here - this avoids // very short-duration microsecond-resolution sleeps that the OS // might treat as zero-length. let mut duration = self.time_so...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
201
260
tokio-rs/tokio:tokio/src/time/driver/mod.rs:7
Ok(()) } } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self) { let now = self.time_source().now(); self.process_at_time(now) } pub(self) fn process_at_time(&self, now: u64) { let mut waker_list: [Option<Waker>; 32] = D...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
241
300
tokio-rs/tokio:tokio/src/time/driver/mod.rs:8
lock = self.lock(); } } } // Update the elapsed cache lock.elapsed = lock.wheel.elapsed(); lock.next_wake = lock .wheel .poll_at() .map(|t| NonZeroU64::new(t).unwrap_or_else(|| NonZeroU64::new(1).unwrap())); drop(l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
281
340
tokio-rs/tokio:tokio/src/time/driver/mod.rs:9
/// Removes and re-adds an entry to the driver. /// /// SAFETY: The timer must be either unregistered, or registered with this /// driver. No other threads are allowed to concurrently manipulate the /// timer at all (the current thread should hold an exclusive reference to /// the `TimerEntry`) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
321
380
tokio-rs/tokio:tokio/src/time/driver/mod.rs:10
Err((entry, super::error::InsertError::Elapsed)) => unsafe { entry.fire(Ok(())) }, } } // Must release lock before invoking waker to avoid the risk of deadlock. }; // The timer was fired synchronously as a result of th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
361
420
tokio-rs/tokio:tokio/src/time/driver/mod.rs:11
if lock.is_shutdown { return; } lock.is_shutdown = true; drop(lock); // Advance time forward to the end of time. self.inner.process_at_time(u64::MAX); self.park.shutdown(); } } impl<P> Drop for Driver<P> where P: Park + 'static, { fn drop(&mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
fcb6d041b9d2fe567b5306e648cbb048b426a49d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/time/driver/mod.rs
401
448
tokio-rs/tokio:tokio/src/time/driver/mod.rs:3
/// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver<P: Park + 'static> { /// Timing backend in use time_source: ClockTime, /// Shared state inner: Handle, /// Parker to delegate to park: P, } /// A structure which handles convers...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
57dffb9dfe9e4c0f12429246540add3975f4a754
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57dffb9dfe9e4c0f12429246540add3975f4a754/tokio/src/time/driver/mod.rs
81
140
tokio-rs/tokio:tokio/src/time/driver/mod.rs:5
/// Creates a new `Driver` instance that uses `park` to block the current /// thread and `time_source` to get the current time and convert to ticks. /// /// Specifying the source of time is useful when testing. pub(crate) fn new(park: P, clock: Clock) -> Driver<P> { let time_source = ClockTime::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/mod.rs
161
220
tokio-rs/tokio:tokio/src/time/driver/mod.rs:6
// Note that we effectively round up to 1ms here - this avoids // very short-duration microsecond-resolution sleeps that the OS // might treat as zero-length. let mut duration = self.time_source.tick_to_duration(when.saturating_sub(now)); if duration > Du...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/mod.rs
201
260
tokio-rs/tokio:tokio/src/time/driver/mod.rs:7
} } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self) { let now = self.time_source().now(); self.process_at_time(now) } pub(self) fn process_at_time(&self, now: u64) { let mut waker_list: [Option<Waker>; 32] = Default::def...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/mod.rs
241
300
tokio-rs/tokio:tokio/src/time/driver/mod.rs:8
} } // Update the elapsed cache lock.elapsed = lock.wheel.elapsed(); lock.next_wake = lock .wheel .poll_at() .map(|t| NonZeroU64::new(t).unwrap_or_else(|| NonZeroU64::new(1).unwrap())); drop(lock); for waker in waker_list[0..waker_id...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/mod.rs
281
340
tokio-rs/tokio:tokio/src/time/driver/mod.rs:9
/// /// SAFETY: The timer must be either unregistered, or registered with this /// driver. No other threads are allowed to concurrently manipulate the /// timer at all (the current thread should hold an exclusive reference to /// the `TimerEntry`) pub(self) unsafe fn reregister(&self, new_tick: u64,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/mod.rs
321
380
tokio-rs/tokio:tokio/src/time/driver/mod.rs:10
}, } } // Must release lock before invoking waker to avoid the risk of deadlock. }; // The timer was fired synchronously as a result of the reregistration. // Wake the waker; this is needed because we might reset _after_ a poll, // and otherwise ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/mod.rs
361
420
tokio-rs/tokio:tokio/src/time/driver/mod.rs:11
} lock.is_shutdown = true; drop(lock); // Advance time forward to the end of time. self.inner.process_at_time(u64::MAX); self.park.shutdown(); } } impl<P> Drop for Driver<P> where P: Park + 'static, { fn drop(&mut self) { self.shutdown(); } } // ===...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
ae67851f11b7cc1f577de8ce21767ce3e2c7aff9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/src/time/driver/mod.rs
401
446
tokio-rs/tokio:tokio/src/time/driver/mod.rs:1
#![cfg_attr(not(feature = "rt"), allow(dead_code))] //! Time driver mod atomic_stack; use self::atomic_stack::AtomicStack; mod entry; pub(super) use self::entry::Entry; mod handle; pub(crate) use self::handle::Handle; use crate::loom::sync::atomic::{AtomicU64, AtomicUsize}; use crate::park::{Park, Unpark}; use cra...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/mod.rs:3
pub(crate) struct Driver<T: Park> { /// Shared state inner: Arc<Inner>, /// Timer wheel wheel: wheel::Wheel, /// Thread parker. The `Driver` park implementation delegates to this. park: T, /// Source of "now" instances clock: Clock, /// True if the driver is being shutdown is...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
81
140
tokio-rs/tokio:tokio/src/time/driver/mod.rs:4
impl<T> Driver<T> where T: Park, { /// Creates a new `Driver` instance that uses `park` to block the current /// thread and `clock` to get the current `Instant`. /// /// Specifying the source of time is useful when testing. pub(crate) fn new(park: T, clock: Clock) -> Driver<T> { let unpa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
121
180
tokio-rs/tokio:tokio/src/time/driver/mod.rs:5
); while let Some(entry) = self.wheel.poll(now) { let when = entry.when_internal().expect("invalid internal entry state"); // Fire the entry entry.fire(when); // Track that the entry has been fired entry.set_when_internal(None); } /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
161
220
tokio-rs/tokio:tokio/src/time/driver/mod.rs:6
fn clear_entry(&mut self, entry: &Arc<Entry>) { self.wheel.remove(entry); entry.set_when_internal(None); } /// Fires the entry if it needs to, otherwise queue it to be processed later. fn add_entry(&mut self, entry: Arc<Entry>, when: u64) { use crate::time::error::InsertError; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
201
260
tokio-rs/tokio:tokio/src/time/driver/mod.rs:7
fn park(&mut self) -> Result<(), Self::Error> { self.process_queue(); match self.wheel.poll_at() { Some(when) => { let now = self.clock.now(); let deadline = self.expiration_instant(when); if deadline > now { let dur = dea...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
241
300
tokio-rs/tokio:tokio/src/time/driver/mod.rs:8
if deadline > now { let duration = cmp::min(deadline - now, duration); if self.clock.is_paused() { self.park.park_timeout(Duration::from_secs(0))?; self.clock.advance(duration); } else { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
281
340
tokio-rs/tokio:tokio/src/time/driver/mod.rs:9
self.park.shutdown(); self.is_shutdown = true; } } impl<T> Drop for Driver<T> where T: Park, { fn drop(&mut self) { self.shutdown(); } } // ===== impl Inner ===== impl Inner { fn new(start: Instant, unpark: Box<dyn Unpark>) -> Inner { Inner { num: AtomicUsize:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
321
380
tokio-rs/tokio:tokio/src/time/driver/mod.rs:10
let mut curr = self.num.load(Relaxed); loop { if curr == MAX_TIMEOUTS { return Err(Error::at_capacity()); } match self .num .compare_exchange_weak(curr, curr + 1, Release, Relaxed) { Ok(_) => return ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
361
412
tokio-rs/tokio:tokio/src/time/driver/mod.rs:11
crate::time::ms(deadline - self.start, crate::time::Round::Up) } } impl fmt::Debug for Inner { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Inner").finish() } } #[cfg(all(test, loom))] mod tests;
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/time/driver/mod.rs
401
412
tokio-rs/tokio:tokio/src/time/driver/mod.rs:1
#![cfg_attr(not(feature = "rt-core"), allow(dead_code))] //! Time driver mod atomic_stack; use self::atomic_stack::AtomicStack; mod entry; pub(super) use self::entry::Entry; mod handle; pub(crate) use self::handle::Handle; use crate::loom::sync::atomic::{AtomicU64, AtomicUsize}; use crate::park::{Park, Unpark}; us...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/time/driver/mod.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/mod.rs:1
//! Time driver mod atomic_stack; use self::atomic_stack::AtomicStack; mod entry; pub(super) use self::entry::Entry; mod handle; pub(crate) use self::handle::Handle; use crate::loom::sync::atomic::{AtomicU64, AtomicUsize}; use crate::park::{Park, Unpark}; use crate::time::{error::Error, wheel}; use crate::time::{Cl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/mod.rs:3
inner: Arc<Inner>, /// Timer wheel wheel: wheel::Wheel, /// Thread parker. The `Driver` park implementation delegates to this. park: T, /// Source of "now" instances clock: Clock, /// True if the driver is being shutdown is_shutdown: bool, } /// Timer state shared between `Driver`, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
81
140
tokio-rs/tokio:tokio/src/time/driver/mod.rs:4
T: Park, { /// Creates a new `Driver` instance that uses `park` to block the current /// thread and `clock` to get the current `Instant`. /// /// Specifying the source of time is useful when testing. pub(crate) fn new(park: T, clock: Clock) -> Driver<T> { let unpark = Box::new(park.unpark())...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
121
180
tokio-rs/tokio:tokio/src/time/driver/mod.rs:5
while let Some(entry) = self.wheel.poll(now) { let when = entry.when_internal().expect("invalid internal entry state"); // Fire the entry entry.fire(when); // Track that the entry has been fired entry.set_when_internal(None); } // Update the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
161
220
tokio-rs/tokio:tokio/src/time/driver/mod.rs:6
self.wheel.remove(entry); entry.set_when_internal(None); } /// Fires the entry if it needs to, otherwise queue it to be processed later. fn add_entry(&mut self, entry: Arc<Entry>, when: u64) { use crate::time::error::InsertError; entry.set_when_internal(Some(when)); match ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
201
260
tokio-rs/tokio:tokio/src/time/driver/mod.rs:7
self.process_queue(); match self.wheel.poll_at() { Some(when) => { let now = self.clock.now(); let deadline = self.expiration_instant(when); if deadline > now { let dur = deadline - now; if self.clock.is_pause...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
241
300
tokio-rs/tokio:tokio/src/time/driver/mod.rs:8
if self.clock.is_paused() { self.park.park_timeout(Duration::from_secs(0))?; self.clock.advance(duration); } else { self.park.park_timeout(duration)?; } } else { self.park....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
281
340
tokio-rs/tokio:tokio/src/time/driver/mod.rs:9
self.is_shutdown = true; } } impl<T> Drop for Driver<T> where T: Park, { fn drop(&mut self) { self.shutdown(); } } // ===== impl Inner ===== impl Inner { fn new(start: Instant, unpark: Box<dyn Unpark>) -> Inner { Inner { num: AtomicUsize::new(0), elapsed: A...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
321
380
tokio-rs/tokio:tokio/src/time/driver/mod.rs:10
if curr == MAX_TIMEOUTS { return Err(Error::at_capacity()); } match self .num .compare_exchange_weak(curr, curr + 1, Release, Relaxed) { Ok(_) => return Ok(()), Err(next) => curr = next, } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
361
410
tokio-rs/tokio:tokio/src/time/driver/mod.rs:11
} impl fmt::Debug for Inner { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Inner").finish() } } #[cfg(all(test, loom))] mod tests;
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
0893841f31542b2b04c5050a8a4a3c45cf867e55
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0893841f31542b2b04c5050a8a4a3c45cf867e55/tokio/src/time/driver/mod.rs
401
410
tokio-rs/tokio:tokio/src/time/driver/mod.rs:1
//! Time driver mod atomic_stack; use self::atomic_stack::AtomicStack; mod entry; pub(super) use self::entry::Entry; mod handle; pub(crate) use self::handle::Handle; use crate::loom::sync::atomic::{AtomicU64, AtomicUsize}; use crate::park::{Park, Unpark}; use crate::time::{wheel, Error}; use crate::time::{Clock, Du...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/driver/mod.rs
1
60
tokio-rs/tokio:tokio/src/time/driver/mod.rs:5
while let Some(entry) = self.wheel.poll(now) { let when = entry.when_internal().expect("invalid internal entry state"); // Fire the entry entry.fire(when); // Track that the entry has been fired entry.set_when_internal(None); } // Update the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/driver/mod.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/src/time/driver/mod.rs
161
220