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/runtime/time/mod.rs:11
// We may have raced with a firing/deregistration, so check before // deregistering. if unsafe { entry.as_ref().might_be_registered() } { lock.remove(entry); } // Now that we have exclusive control of this entry, mint a handle to reinsert it. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
bd4ccae184b0359cb88f9ebc2ba157867e1eee0e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd4ccae184b0359cb88f9ebc2ba157867e1eee0e/tokio/src/runtime/time/mod.rs
401
460
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:12
// 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 awoken to poll again. if let Some(waker) = waker { waker.wake(); } } cfg_test_util! { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
bd4ccae184b0359cb88f9ebc2ba157867e1eee0e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd4ccae184b0359cb88f9ebc2ba157867e1eee0e/tokio/src/runtime/time/mod.rs
441
491
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:13
&self, shard_id: u32, ) -> crate::loom::sync::MutexGuard<'_, Wheel> { let index = shard_id % (self.0.len() as u32); // Safety: This modulo operation ensures that the index is not out of bounds. unsafe { self.0.get_unchecked(index as usize) }.lock() } } #[cfg(test)] mod tests;
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
bd4ccae184b0359cb88f9ebc2ba157867e1eee0e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd4ccae184b0359cb88f9ebc2ba157867e1eee0e/tokio/src/runtime/time/mod.rs
481
491
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
1
60
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:3
/// The implementation maintains six wheels arranged in a set of levels. As the /// levels go up, the slots of the associated wheel represent larger intervals /// of time. At each level, the wheel has 64 slots. Each slot covers a range of /// time equal to the wheel at the lower level. At level zero, each slot /// repr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
81
140
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
/// Number of entries in the sharded timer wheels. wheels_len: u32, /// True if the driver is being shutdown. pub(super) is_shutdown: AtomicBool, // When `true`, a call to `park_timeout` should immediately return and time // should not advance. One reason for this to be `true` is if the task /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
is_shutdown: AtomicBool::new(false), #[cfg(feature = "test-util")] did_wake: AtomicBool::new(false), }, }; let driver = Driver { park }; (driver, handle) } pub(crate) fn park(&mut self, handle: &driver::Handle) { self.park_internal(h...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
let expiration_time = { let mut wheels_lock = rt_handle .time() .inner .wheels .write() .expect("Timer wheel shards poisoned"); let expiration_time = wheels_lock .0 .iter_mut() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
} } None => { if let Some(duration) = limit { self.park_thread_timeout(rt_handle, duration); } else { self.park.park(rt_handle); } } } // Process pending timers after waking up ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
fn park_thread_timeout(&mut self, rt_handle: &driver::Handle, duration: Duration) { self.park.park_timeout(rt_handle, duration); } } } // Helper function to turn expiration_time into next_wake_time. // Since the `park_timeout` will round up to 1ms for avoiding very // short-duration microsecond...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:9
self.inner.next_wake.store(next_wake_time(expiration_time)); } // Returns the next wakeup time of this shard. pub(self) fn process_at_sharded_time(&self, id: u32, mut now: u64) -> Option<u64> { let mut waker_list = WakeList::new(); let mut wheels_lock = self .inner ....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
.read() .expect("Timer wheel shards poisoned"); lock = wheels_lock.lock_sharded_wheel(id); } } } let next_wake_up = lock.poll_at(); drop(lock); drop(wheels_lock); waker_list.wake_all(); next_wake_up ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
361
420
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:11
/// 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/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
401
460
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:12
Ok(when) => { if self .inner .next_wake .load() .map(|next_wake| when < next_wake.get()) .unwrap_or(true) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
441
500
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:13
// Check whether the driver has been shutdown pub(super) fn is_shutdown(&self) -> bool { self.is_shutdown.load(Ordering::SeqCst) } // Gets the number of shards. fn get_shard_size(&self) -> u32 { self.wheels_len } } impl fmt::Debug for Inner { fn fmt(&self, fmt: &mut fmt::Format...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
479a56a010d25f86207841ec4fcc685402addcad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/479a56a010d25f86207841ec4fcc685402addcad/tokio/src/runtime/time/mod.rs
481
513
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
1
60
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:3
/// levels go up, the slots of the associated wheel represent larger intervals /// of time. At each level, the wheel has 64 slots. Each slot covers a range of /// time equal to the wheel at the lower level. At level zero, each slot /// represents one millisecond of time. /// /// The wheels are: /// /// * Level 0: 64 x ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
81
140
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
pub(super) is_shutdown: AtomicBool, // When `true`, a call to `park_timeout` should immediately return and time // should not advance. One reason for this to be `true` is if the task // passed to `Runtime::block_on` called `task::yield_now()`. // // While it may look racy, it only has any effect wh...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
(driver, handle) } pub(crate) fn park(&mut self, handle: &driver::Handle) { self.park_internal(handle, None); } pub(crate) fn park_timeout(&mut self, handle: &driver::Handle, duration: Duration) { self.park_internal(handle, Some(duration)); } pub(crate) fn shutdown(&mut self, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
rt_handle .time() .inner .next_wake .store(next_wake_time(expiration_time)); // Safety: After updating the `next_wake`, we drop all the locks. drop(locks); match expiration_time { Some(when) => { let now = handle.time_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
handle.process(rt_handle.clock()); } cfg_test_util! { fn park_thread_timeout(&mut self, rt_handle: &driver::Handle, duration: Duration) { let handle = rt_handle.time(); let clock = rt_handle.clock(); if clock.can_auto_advance() { self.park.park_timeo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
// Some(i) => Some(i) fn next_wake_time(expiration_time: Option<u64>) -> Option<NonZeroU64> { expiration_time.and_then(|v| { if v == 0 { NonZeroU64::new(1) } else { NonZeroU64::new(v) } }) } impl Handle { /// Runs timer related logic, and returns the next wak...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:9
// hardware clock to be monotonic. // // See <https://github.com/tokio-rs/tokio/issues/3619> for more information. now = lock.elapsed(); } while let Some(entry) = lock.poll(now) { debug_assert!(unsafe { entry.is_pending() }); // SAFETY: We ho...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
pub(self) unsafe fn clear_entry(&self, entry: NonNull<TimerShared>) { unsafe { let mut lock = self.inner.lock_sharded_wheel(entry.as_ref().shard_id()); if entry.as_ref().might_be_registered() { lock.remove(entry); } entry.as_ref().handle().fire(O...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
361
420
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:11
// Note: We don't have to worry about racing with some other resetting // thread, because add_entry and reregister require exclusive control of // the timer entry. match unsafe { lock.insert(entry) } { Ok(when) => { if self ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
401
460
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:12
} // ===== impl Inner ===== impl Inner { /// Locks the driver's sharded wheel structure. pub(super) fn lock_sharded_wheel( &self, shard_id: u32, ) -> crate::loom::sync::MutexGuard<'_, Wheel> { let index = shard_id % (self.wheels.len() as u32); // Safety: This modulo operati...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
47210a8e6eeb82b51aa778074fdc4d757b953b8c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47210a8e6eeb82b51aa778074fdc4d757b953b8c/tokio/src/runtime/time/mod.rs
441
474
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
1
60
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
(driver, handle) } pub(crate) fn park(&mut self, handle: &driver::Handle) { self.park_internal(handle, None); } pub(crate) fn park_timeout(&mut self, handle: &driver::Handle, duration: Duration) { self.park_internal(handle, Some(duration)); } pub(crate) fn shutdown(&mut self, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
.time() .inner .next_wake .store(next_wake_time(expiration_time)); match expiration_time { Some(when) => { let now = handle.time_source.now(rt_handle.clock()); // Note that we effectively round up to 1ms here - this avoids ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
let handle = rt_handle.time(); let clock = rt_handle.clock(); if clock.can_auto_advance() { self.park.park_timeout(rt_handle, Duration::from_secs(0)); // If the time driver was woken, then the park completed // before the "duration" elapsed (usua...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
} else { NonZeroU64::new(v) } }) } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self, clock: &Clock) { let now = self.time_source().now(clock); // For fairness, randomly select one to start. let shards = self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:9
while let Some(expiration) = lock.poll(now) { lock.set_elapsed(expiration.deadline); // It is critical for `GuardedLinkedList` safety that the guard node is // pinned in memory and is not dropped until the guarded list is dropped. let guard = TimerShared::new(id); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
// Safety: This Entry has not expired. unsafe { lock.reinsert_entry(entry, deadline, state) }; } } } lock.occupied_bit_maintain(&expiration); } let next_wake_up = lock.poll_at(); drop(lock); waker_list....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
361
420
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:11
/// 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, unpark: &IoHandle, new_tick: u64, entry: NonNull<TimerShared>, )...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
401
460
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:12
None } Err((entry, crate::time::error::InsertError::Elapsed)) => unsafe { entry.fire(Ok(())) }, } } // Must release lock before invoking waker to avoid the risk of deadlock. }; /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
441
499
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:13
// Check whether the driver has been shutdown pub(super) fn is_shutdown(&self) -> bool { self.is_shutdown.load(Ordering::SeqCst) } // Gets the number of shards. fn get_shard_size(&self) -> u32 { self.wheels.len() as u32 } } impl fmt::Debug for Inner { fn fmt(&self, fmt: &mut fm...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
8480a180e6ffdd0ec0ec213a9bebcda2445fc541
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8480a180e6ffdd0ec0ec213a9bebcda2445fc541/tokio/src/runtime/time/mod.rs
481
499
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
} else { NonZeroU64::new(v) } }) } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self, clock: &Clock) { let now = self.time_source().now(clock); // For fairness, randomly select one to start. let shards = self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:9
while let Some(entry) = lock.poll(now) { debug_assert!(unsafe { entry.is_pending() }); // SAFETY: We hold the driver lock, and just removed the entry from any linked lists. if let Some(waker) = unsafe { entry.fire(Ok(())) } { waker_list.push(waker); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
lock.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. No other threads are allowed to concurrently manipulate the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210/tokio/src/runtime/time/mod.rs
361
420
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:11
Ok(when) => { if self .inner .next_wake .load() .map(|next_wake| when < next_wake.get()) .unwrap_or(true) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210/tokio/src/runtime/time/mod.rs
401
460
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:12
/// Locks the driver's sharded wheel structure. pub(super) fn lock_sharded_wheel( &self, shard_id: u32, ) -> crate::loom::sync::MutexGuard<'_, Wheel> { let index = shard_id % (self.wheels.len() as u32); // Safety: This modulo operation ensures that the index is not out of bounds....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210/tokio/src/runtime/time/mod.rs
441
469
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
1
60
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:3
/// [paper]: http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf /// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver { /// Parker to delegate to. park: IoStack, } /// Timer state shared between `D...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
81
140
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
/// 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: IoStack, clock: &Clock) -> (Driver, Handle) { let time_source...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
handle.inner.is_shutdown.store(true, Ordering::SeqCst); // Advance time forward to the end of time. handle.process_at_time(u64::MAX); self.park.shutdown(rt_handle); } fn park_internal(&mut self, rt_handle: &driver::Handle, limit: Option<Duration>) { let handle = rt_handle.tim...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
} } None => { if let Some(duration) = limit { self.park_thread_timeout(rt_handle, duration); } else { self.park.park(rt_handle); } } } // Process pending timers after waking up ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
fn park_thread_timeout(&mut self, rt_handle: &driver::Handle, duration: Duration) { self.park.park_timeout(rt_handle, duration); } } } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self, clock: &Clock) { let now = self.time_so...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
// Wake a batch of wakers. To avoid deadlock, we must do this with the lock temporarily dropped. drop(lock); for waker in waker_list.iter_mut() { waker.take().unwrap().wake(); } waker_idx = 0; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
match unsafe { lock.wheel.insert(entry) } { Ok(when) => { if lock .next_wake .map(|next_wake| when < next_wake.get()) .unwrap_or(true) { unp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
361
418
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:11
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.is_shutdown.load(Ordering::SeqCst) } } impl fmt::Debug for Inner { fn fmt(&self, fmt: &mut ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
61fcc3bc0b24f23036a5bc20fe8eba3977924a05
github
async-runtime
https://github.com/tokio-rs/tokio/blob/61fcc3bc0b24f23036a5bc20fe8eba3977924a05/tokio/src/runtime/time/mod.rs
401
418
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:3
/// [paper]: http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf /// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver { /// Parker to delegate to. park: IoStack, } /// Timer state shared between `D...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
81
140
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
// ===== impl Driver ===== impl Driver { /// 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: IoStack, clock: &Clock)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
if handle.is_shutdown() { return; } handle.inner.is_shutdown.store(true, Ordering::SeqCst); // Advance time forward to the end of time. handle.process_at_time(u64::MAX); self.park.shutdown(rt_handle); } fn park_internal(&mut self, rt_handle: &driver::Hand...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
self.park_thread_timeout(rt_handle, duration); } else { self.park.park_timeout(rt_handle, Duration::from_secs(0)); } } None => { if let Some(duration) = limit { self.park_thread_timeout(rt_handle, duration); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
} } cfg_not_test_util! { fn park_thread_timeout(&mut self, rt_handle: &driver::Handle, duration: Duration) { self.park.park_timeout(rt_handle, duration); } } } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self, clock...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
waker_idx += 1; if waker_idx == waker_list.len() { // Wake a batch of wakers. To avoid deadlock, we must do this with the lock temporarily dropped. drop(lock); for waker in waker_list.iter_mut() { waker.take().unwrap()...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:9
/// SAFETY: The timer must not be registered with some other driver, and /// `add_entry` must not be called concurrently. pub(self) unsafe fn clear_entry(&self, entry: NonNull<TimerShared>) { unsafe { let mut lock = self.inner.lock(); if entry.as_ref().might_be_registered() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
} else { entry.set_expiration(new_tick); // Note: We don't have to worry about racing with some other resetting // thread, because add_entry and reregister require exclusive control of // the timer entry. match unsafe { lock.wheel.insert(e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
361
420
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:11
} // ===== impl Inner ===== impl Inner { /// 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.is_shutdow...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/time/mod.rs
401
424
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
// ===== impl Driver ===== impl Driver { /// 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: IoStack, clock: &Clock)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
2a54ad01d0945c851a093849c83019de69e98dee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a54ad01d0945c851a093849c83019de69e98dee/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
self.park_thread_timeout(rt_handle, duration); } else { self.park.park_timeout(rt_handle, Duration::from_secs(0)); } } None => { if let Some(duration) = limit { self.park_thread_timeout(rt_handle, duration); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
2a54ad01d0945c851a093849c83019de69e98dee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a54ad01d0945c851a093849c83019de69e98dee/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
} } cfg_not_test_util! { fn park_thread_timeout(&mut self, rt_handle: &driver::Handle, duration: Duration) { self.park.park_timeout(rt_handle, duration); } } } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self, clock...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
2a54ad01d0945c851a093849c83019de69e98dee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a54ad01d0945c851a093849c83019de69e98dee/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
waker_idx += 1; if waker_idx == waker_list.len() { // Wake a batch of wakers. To avoid deadlock, we must do this with the lock temporarily dropped. drop(lock); for waker in waker_list.iter_mut() { waker.take().unwrap()...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
2a54ad01d0945c851a093849c83019de69e98dee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a54ad01d0945c851a093849c83019de69e98dee/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
abf5d28f2ccaf55ea264f1bea7a1ac1bac6fe98b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/abf5d28f2ccaf55ea264f1bea7a1ac1bac6fe98b/tokio/src/runtime/time/mod.rs
1
60
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:3
/// [paper]: http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf /// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver { /// Parker to delegate to. park: IoStack, } /// Timer state shared between `D...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
81
140
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
// ===== impl Driver ===== impl Driver { /// 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: IoStack, clock: Clock) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
if handle.is_shutdown() { return; } handle.inner.is_shutdown.store(true, Ordering::SeqCst); // Advance time forward to the end of time. handle.process_at_time(u64::MAX); self.park.shutdown(rt_handle); } fn park_internal(&mut self, rt_handle: &driver::Hand...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
self.park_thread_timeout(rt_handle, duration); } else { self.park.park_timeout(rt_handle, Duration::from_secs(0)); } } None => { if let Some(duration) = limit { self.park_thread_timeout(rt_handle, duration); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
cfg_not_test_util! { fn park_thread_timeout(&mut self, rt_handle: &driver::Handle, duration: Duration) { self.park.park_timeout(rt_handle, duration); } } } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self) { let now ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
if waker_idx == waker_list.len() { // Wake a batch of wakers. To avoid deadlock, we must do this with the lock temporarily dropped. drop(lock); for waker in waker_list.iter_mut() { waker.take().unwrap().wake(); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:9
pub(self) unsafe fn clear_entry(&self, entry: NonNull<TimerShared>) { unsafe { let mut lock = self.inner.lock(); if entry.as_ref().might_be_registered() { lock.wheel.remove(entry); } entry.as_ref().handle().fire(Ok(())); } } /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
// Note: We don't have to worry about racing with some other resetting // thread, because add_entry and reregister require exclusive control of // the timer entry. match unsafe { lock.wheel.insert(entry) } { Ok(when) => { if loc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
361
420
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:11
// ===== impl Inner ===== impl Inner { /// 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.is_shutdown.l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
e14ca72e68fbfa04f12408ed916bf5f857dfa232
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/time/mod.rs
401
422
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
self.park_thread_timeout(rt_handle, duration); } else { self.park.park_timeout(rt_handle, Duration::from_secs(0)); } } None => { if let Some(duration) = limit { self.park_thread_timeout(rt_handle, duration); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
80568dfc6da83f9c68c63bd9de66bcda295c76a9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/80568dfc6da83f9c68c63bd9de66bcda295c76a9/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
1
60
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:3
/// [paper]: http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf /// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver { /// Timing backend in use. time_source: TimeSource, /// Parker to delegat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
81
140
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
elapsed: u64, /// The earliest time at which we promise to wake up without unparking. next_wake: Option<NonZeroU64>, /// Timer wheel. wheel: wheel::Wheel, } // ===== impl Driver ===== impl Driver { /// Creates a new `Driver` instance that uses `park` to block the current /// thread and `time...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
#[cfg(feature = "test-util")] did_wake, }; (driver, handle) } pub(crate) fn park(&mut self, handle: &driver::Handle) { self.park_internal(handle, None) } pub(crate) fn park_timeout(&mut self, handle: &driver::Handle, duration: Duration) { self.park_internal...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
drop(lock); match next_wake { 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-leng...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
// If the time driver was woken, then the park completed // before the "duration" elapsed (usually caused by a // yield in `Runtime::block_on`). In this case, we don't // advance the clock. if !self.did_wake() { // Simulate advancing ti...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
if now < lock.elapsed { // Time went backwards! This normally shouldn't happen as the Rust language // guarantees that an Instant is monotonic, but can happen when running // Linux in a VM on a Windows host due to std incorrectly trusting the // hardware clock to be monot...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:9
drop(lock); for waker in waker_list[0..waker_idx].iter_mut() { waker.take().unwrap().wake(); } } /// Removes a registered timer from the driver. /// /// The timer will be moved to the cancelled state. Wakers will _not_ be /// invoked. If the timer is already completed, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
entry: NonNull<TimerShared>, ) { let waker = unsafe { let mut lock = self.get().lock(); // We may have raced with a firing/deregistration, so check before // deregistering. if unsafe { entry.as_ref().might_be_registered() } { lock.wheel.remove...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
361
420
tokio-rs/tokio:tokio/src/runtime/time/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 awoken to poll again. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/time/mod.rs
401
434
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
1
60
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
elapsed: u64, /// The earliest time at which we promise to wake up without unparking. next_wake: Option<NonZeroU64>, /// Timer wheel. wheel: wheel::Wheel, } // ===== impl Driver ===== impl Driver { /// Creates a new `Driver` instance that uses `park` to block the current /// thread and `time...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
#[cfg(feature = "test-util")] did_wake, }; (driver, handle) } pub(crate) fn park(&mut self, handle: &Handle) { self.park_internal(handle, None) } pub(crate) fn park_timeout(&mut self, handle: &Handle, duration: Duration) { self.park_internal(handle, Some(du...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
match next_wake { 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. l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
// yield in `Runtime::block_on`). In this case, we don't // advance the clock. if !self.did_wake() { // Simulate advancing time clock.advance(duration); } } else { self.park.park_timeout(duration); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
241
300
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:8
// Linux in a VM on a Windows host due to std incorrectly trusting the // hardware clock to be monotonic. // // See <https://github.com/tokio-rs/tokio/issues/3619> for more information. now = lock.elapsed; } while let Some(entry) = lock.wheel.poll(now) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
281
340
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:9
for waker in waker_list[0..waker_idx].iter_mut() { waker.take().unwrap().wake(); } } /// Removes a registered timer from the driver. /// /// The timer will be moved to the cancelled state. Wakers will _not_ be /// invoked. If the timer is already completed, this function is a no...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
321
380
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:10
let mut lock = self.get().lock(); // We may have raced with a firing/deregistration, so check before // deregistering. if unsafe { entry.as_ref().might_be_registered() } { lock.wheel.remove(entry); } // Now that we have exclusive control of t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
361
420
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:11
// 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 awoken to poll again. if let Some(waker) = waker { waker.wake(); } } } // ===== impl Inner ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/time/mod.rs
401
431
tokio-rs/tokio:tokio/src/runtime/time/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/runtime/time/mod.rs
MIT
3f379abda4f980086ab44f4912eff877bdb75120
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3f379abda4f980086ab44f4912eff877bdb75120/tokio/src/runtime/time/mod.rs
1
60
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:3
/// [paper]: http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf /// [sleep]: crate::time::Sleep /// [timeout]: crate::time::Timeout /// [interval]: crate::time::Interval #[derive(Debug)] pub(crate) struct Driver { /// Timing backend in use. time_source: TimeSource, /// Parker to delegat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
3f379abda4f980086ab44f4912eff877bdb75120
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3f379abda4f980086ab44f4912eff877bdb75120/tokio/src/runtime/time/mod.rs
81
140
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:4
next_wake: Option<NonZeroU64>, /// Timer wheel. wheel: wheel::Wheel, } // ===== impl Driver ===== impl Driver { /// 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
3f379abda4f980086ab44f4912eff877bdb75120
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3f379abda4f980086ab44f4912eff877bdb75120/tokio/src/runtime/time/mod.rs
121
180
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:5
pub(crate) fn shutdown(&mut self, handle: &Handle) { if handle.is_shutdown() { return; } handle.get().is_shutdown.store(true, Ordering::SeqCst); // Advance time forward to the end of time. handle.process_at_time(u64::MAX); self.park.shutdown(); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
3f379abda4f980086ab44f4912eff877bdb75120
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3f379abda4f980086ab44f4912eff877bdb75120/tokio/src/runtime/time/mod.rs
161
220
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:6
} else { self.park.park_timeout(Duration::from_secs(0)); } } None => { if let Some(duration) = limit { self.park_thread_timeout(duration); } else { self.park.park(); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
3f379abda4f980086ab44f4912eff877bdb75120
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3f379abda4f980086ab44f4912eff877bdb75120/tokio/src/runtime/time/mod.rs
201
260
tokio-rs/tokio:tokio/src/runtime/time/mod.rs:7
} cfg_not_test_util! { fn park_thread_timeout(&mut self, duration: Duration) { self.park.park_timeout(duration); } } } impl Handle { /// Runs timer related logic, and returns the next wakeup time pub(self) fn process(&self) { let now = self.time_source().now(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/time/mod.rs
MIT
3f379abda4f980086ab44f4912eff877bdb75120
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3f379abda4f980086ab44f4912eff877bdb75120/tokio/src/runtime/time/mod.rs
241
300