@@ -58,7 +58,6 @@ use crate::loom::cell::UnsafeCell;
58
58
use crate :: loom:: sync:: atomic:: AtomicU64 ;
59
59
use crate :: loom:: sync:: atomic:: Ordering ;
60
60
61
- use crate :: runtime:: context;
62
61
use crate :: runtime:: scheduler;
63
62
use crate :: sync:: AtomicWaker ;
64
63
use crate :: time:: Instant ;
@@ -329,8 +328,6 @@ pub(super) type EntryList = crate::util::linked_list::LinkedList<TimerShared, Ti
329
328
///
330
329
/// Note that this structure is located inside the `TimerEntry` structure.
331
330
pub ( crate ) struct TimerShared {
332
- /// The shard id. We should never change it.
333
- shard_id : u32 ,
334
331
/// A link within the doubly-linked list of timers on a particular level and
335
332
/// slot. Valid only if state is equal to Registered.
336
333
///
@@ -371,9 +368,8 @@ generate_addr_of_methods! {
371
368
}
372
369
373
370
impl TimerShared {
374
- pub ( super ) fn new ( shard_id : u32 ) -> Self {
371
+ pub ( super ) fn new ( ) -> Self {
375
372
Self {
376
- shard_id,
377
373
cached_when : AtomicU64 :: new ( 0 ) ,
378
374
pointers : linked_list:: Pointers :: new ( ) ,
379
375
state : StateCell :: default ( ) ,
@@ -442,11 +438,6 @@ impl TimerShared {
442
438
pub ( super ) fn might_be_registered ( & self ) -> bool {
443
439
self . state . might_be_registered ( )
444
440
}
445
-
446
- /// Gets the shard id.
447
- pub ( super ) fn shard_id ( & self ) -> u32 {
448
- self . shard_id
449
- }
450
441
}
451
442
452
443
unsafe impl linked_list:: Link for TimerShared {
@@ -494,10 +485,8 @@ impl TimerEntry {
494
485
fn inner ( & self ) -> & TimerShared {
495
486
let inner = unsafe { & * self . inner . get ( ) } ;
496
487
if inner. is_none ( ) {
497
- let shard_size = self . driver . driver ( ) . time ( ) . inner . get_shard_size ( ) ;
498
- let shard_id = generate_shard_id ( shard_size) ;
499
488
unsafe {
500
- * self . inner . get ( ) = Some ( TimerShared :: new ( shard_id ) ) ;
489
+ * self . inner . get ( ) = Some ( TimerShared :: new ( ) ) ;
501
490
}
502
491
}
503
492
return inner. as_ref ( ) . unwrap ( ) ;
@@ -654,23 +643,3 @@ impl Drop for TimerEntry {
654
643
unsafe { Pin :: new_unchecked ( self ) } . as_mut ( ) . cancel ( ) ;
655
644
}
656
645
}
657
-
658
- // Generates a shard id. If current thread is a worker thread, we use its worker index as a shard id.
659
- // Otherwise, we use a random number generator to obtain the shard id.
660
- cfg_rt ! {
661
- fn generate_shard_id( shard_size: u32 ) -> u32 {
662
- let id = context:: with_scheduler( |ctx| match ctx {
663
- Some ( scheduler:: Context :: CurrentThread ( _ctx) ) => 0 ,
664
- #[ cfg( feature = "rt-multi-thread" ) ]
665
- Some ( scheduler:: Context :: MultiThread ( ctx) ) => ctx. get_worker_index( ) as u32 ,
666
- None => context:: thread_rng_n( shard_size) ,
667
- } ) ;
668
- id % shard_size
669
- }
670
- }
671
-
672
- cfg_not_rt ! {
673
- fn generate_shard_id( shard_size: u32 ) -> u32 {
674
- context:: thread_rng_n( shard_size)
675
- }
676
- }
0 commit comments