Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: small implementation cleanups #6517

Merged
merged 11 commits into from May 1, 2024

Commits on Apr 25, 2024

  1. time: use compare_exchange_weak in StateCell::mark_pending

    `StateCell::mark_pending` already uses a loop to retry the
    compare exchange operation if it fails.
    
    The logic within the loop would handle a spurious failure
    like any other failure, so `compare_exchange_weak` makes
    the implementation more efficient for some platforms.
    paolobarbolini committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    bda0d8f View commit details
    Browse the repository at this point in the history
  2. time: use saturating_duration_since in TimeSource::instant_to_tick

    This replaces a manual implementation of
    `Instant::saturating_duration_since` with the actual one.
    
    Clippy already catches this for primitive integer types via the
    `manual_saturating_arithmetic` lint, as demonstrated by the following
    example:
    
    ```rs
    fn saturating_sub(val: usize, n: usize) -> usize {
        val.checked_sub(n).unwrap_or(0)
    }
    ```
    paolobarbolini committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    47a8f06 View commit details
    Browse the repository at this point in the history
  3. time: use array::from_fn in Level::new

    As explained by the comment removed by this commit earlier Rust
    versions didn't have an ergonomic way of building arrays of any
    size of non-Copy types. Rust 1.63 stabilized `array::from_fn`,
    fixing the above issue and by making it easy to construct arrays
    from a constructor.
    paolobarbolini committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    a76b09c View commit details
    Browse the repository at this point in the history
  4. time: use array instead of Vec in Wheel::levels

    This replaces `Wheel::levels`, currently represented as a
    `Vec` of 6 elements, into an array.
    
    This should help eliminate some bounds checks from accesses
    to `levels`.
    
    This changes the size of `Wheel` from 48 bytes to 32 bytes
    on x86_64. The initial implementation didn't Box the array,
    resulting into `Wheel` having a size of 6264 bytes and loom
    tests overflowing their stack.
    paolobarbolini committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    79559ac View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    2ccecf8 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    404aafc View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    368a4dd View commit details
    Browse the repository at this point in the history
  8. time: improve fmt

    paolobarbolini committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    50a9245 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    8d97f9b View commit details
    Browse the repository at this point in the history
  10. time: use WakeList in Handle::process_at_time

    Replaces the manual implementation of a waker list with `WakeList`.
    paolobarbolini committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    49feda1 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    c329e01 View commit details
    Browse the repository at this point in the history