event: add scaled timer#11806
Conversation
Add a ScaledTimer interface that can be used to produce timers with min and max timeout values. The choice of which is used is made by the producer, independent of the user of the timer object. Signed-off-by: Alex Konradi <akonradi@google.com>
|
/assign @antoniovicente |
No need to use the actual TimerImpl in ScaledTimerImpl since it can get by with only on the public interface methods. Signed-off-by: Alex Konradi <akonradi@google.com>
| * @param object supplies an optional scope for the duration of the alarm. | ||
| */ | ||
| virtual void enableHRTimer(const std::chrono::microseconds& min_us, | ||
| const std::chrono::microseconds& max_us, |
There was a problem hiding this comment.
Please remove enableHRTimer. We don't really need it and having it adds significant complexity to the implementation; consider need for templates and visitors to perform updates.
There was a problem hiding this comment.
Yeah, I agree. We should keep it in the base timer interface, since Nighthawk needs it (or discuss more with @oschaaf), but probably not needed any place you want scaled timers.
| * timer, only producers. | ||
| * @param scale_factor The scale factor, which will be clipped to the range [0, 1]. | ||
| */ | ||
| void setScaleFactor(double scale_factor); |
There was a problem hiding this comment.
How do you plan to collect all timer instances so you can apply the scale factor to them? Note that applying the scale factor to all the instances by doing a linear scan would likely prove prohibitively expensive.
htuch
left a comment
There was a problem hiding this comment.
Makes sense to me structurally based on our last chat.
| * @param object supplies an optional scope for the duration of the alarm. | ||
| */ | ||
| virtual void enableHRTimer(const std::chrono::microseconds& min_us, | ||
| const std::chrono::microseconds& max_us, |
There was a problem hiding this comment.
Yeah, I agree. We should keep it in the base timer interface, since Nighthawk needs it (or discuss more with @oschaaf), but probably not needed any place you want scaled timers.
|
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
|
This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Commit Message:
Add a ScaledTimer interface and impl that can be used to produce timers with min
and max timeout values. The choice of the actual duration is used is made by the
producer, independent of the user of the timer object.
Additional Description: this code provides a direct libevent-based alternative to #11773. The code isn't used anywhere, hence the low risk level.
Risk Level: low
Testing: built code
Docs Changes: none
Release Notes: none
#11427
/cc @htuch, @antoniovicente