Skip to content

Commit

Permalink
limit timer cleanup (#509)
Browse files Browse the repository at this point in the history
* Add include guards.

* use std::min
  • Loading branch information
bakerstu authored Jan 25, 2021
1 parent 35501ce commit e24c7a5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/utils/LimitTimer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
* @date 9 January 2021
*/

#ifndef _UTILS_LIMITTIMER_HXX_
#define _UTILS_LIMITTIMER_HXX_

#include <algorithm>

#include "executor/Timer.hxx"

/// This timer takes care of limiting the number of speed updates we send
Expand All @@ -49,7 +54,7 @@ public:
std::function<void()> callback)
: Timer(ex->active_timers())
, updateDelayMsec_(update_delay_msec)
, bucket_(max_tokens > 127 ? 127 : max_tokens)
, bucket_(std::min(static_cast<uint8_t>(127), max_tokens))
, bucketMax_(max_tokens)
, needUpdate_(false)
, callback_(callback)
Expand Down Expand Up @@ -133,3 +138,4 @@ private:
std::function<void()> callback_;
};

#endif // _UTILS_LIMITTIMER_HXX_

0 comments on commit e24c7a5

Please sign in to comment.