Skip to content

Commit

Permalink
test(maitake): unbreak loom tests (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Feb 25, 2024
1 parent 3265552 commit c541ac0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion maitake/src/time/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ impl Timer {
clock::dur_to_ticks(self.clock.tick_duration(), duration)
}

fn advance_locked(&self, core: &mut MutexGuard<'_, wheel::Core>) -> Turn {
fn advance_locked(&self, core: &mut wheel::Core) -> Turn {
// take any pending ticks.
let pending_ticks = self.pending_ticks.swap(0, AcqRel) as Ticks;
// we do two separate `advance` calls here instead of advancing once
Expand Down
3 changes: 1 addition & 2 deletions maitake/src/time/timer/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ impl Future for Sleep<'_> {
let ptr =
unsafe { ptr::NonNull::from(Pin::into_inner_unchecked(this.entry.as_mut())) };
// Acquire the wheel lock to insert the sleep.
let mut core: maitake_sync::spin::MutexGuard<'_, crate::time::timer::wheel::Core> =
this.timer.core();
let mut core = this.timer.core();

// While we are holding the wheel lock, go ahead and advance the
// timer, too. This way, the timer wheel gets advanced more
Expand Down
4 changes: 4 additions & 0 deletions maitake/src/time/timer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ impl ClockHandle {
self.advance_ticks_inner(duration.as_millis() as u64)
}

// This function isn't used in loom tests.
#[cfg_attr(loom, allow(dead_code))]
pub fn advance_ticks(&self, ticks: Ticks) {
info!(ticks, "advancing test clock by");
self.advance_ticks_inner(ticks)
Expand All @@ -71,6 +73,8 @@ impl ClockHandle {
);
}

// This function isn't used in loom tests.
#[cfg_attr(loom, allow(dead_code))]
pub fn ticks(&self) -> Ticks {
self.0.now.load(Ordering::SeqCst)
}
Expand Down

0 comments on commit c541ac0

Please sign in to comment.