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

Replace benbjohnson/clock with custom MockClock #1349

Merged
merged 6 commits into from
Sep 9, 2023

Commits on Sep 8, 2023

  1. Drop frozen dependency benbjohnson/clock

    This drops the dependency on benbjohnson/clock
    in favor of a simple hand-rolled mock clock implementation.
    
    The core of the functionality of MockClock is provided by the following:
    
    - waiters: a min-heap of functions waiting to be executed
    - runAt: schedules a function to be executed when time progresses
    - Add: moves time forward, running all functions in range
    
    The rest of the time functionality can be built upon these pieces.
    
    Note that nothing happens until Add is called.
    There are no goroutines running additional work in the background.
    
    Resolves uber-go#1331
    abhinav committed Sep 8, 2023
    Configuration menu
    Copy the full SHA
    f39d8d1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    bb3e6db View commit details
    Browse the repository at this point in the history
  3. chore(Add): More readable loop

    Instead of a `PopLTE` twice, just use a `for { ... }` and break inside.
    abhinav committed Sep 8, 2023
    Configuration menu
    Copy the full SHA
    81e16be View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8b81867 View commit details
    Browse the repository at this point in the history
  5. fix(waiterHeap): Zero-out popped slice slots

    Avoids memory leaks because the waiter holds a function reference.
    abhinav committed Sep 8, 2023
    Configuration menu
    Copy the full SHA
    dee5232 View commit details
    Browse the repository at this point in the history
  6. chore: Drop the heap

    Use a slice of waiters, sort it each `Add` call.
    Simpler, less efficient implementation.
    abhinav committed Sep 8, 2023
    Configuration menu
    Copy the full SHA
    74f27a8 View commit details
    Browse the repository at this point in the history