15using namespace boost::posix_time;
19 aggressivity_(1), rate_(0), late_sent_(false) {
24 aggressivity_(aggressivity), rate_(rate), late_sent_(false) {
27 << aggressivity <<
", expected value is greater than 0");
31 <<
", expected non-negative value");
46 uint64_t due_exchanges = 0;
51 time_duration duration = period.length();
55 static_cast<double>(duration.fractional_seconds()) /
56 static_cast<double>(time_duration::ticks_per_second());
57 due_factor +=
static_cast<double>(duration.total_seconds());
60 due_exchanges =
static_cast<uint64_t
>(due_factor *
getRate());
62 if (due_exchanges == 0) {
76 return (due_exchanges);
81boost::posix_time::ptime
83 return (microsec_clock::universal_time());
111 duration = time_duration::ticks_per_second() /
getRate();
124 if (aggressivity < 1) {
126 << aggressivity <<
", expected value is greater than 0");
135 <<
", expected non-negative value");
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when an unexpected error condition occurs.
int getRate() const
Returns the rate.
static boost::posix_time::ptime currentTime()
Convenience function returning current time.
int aggressivity_
Holds an aggressivity value.
int getAggressivity() const
Returns the value of aggressivity.
RateControl()
Default constructor.
bool late_sent_
A flag which indicates that the calculated due time is in the past.
boost::posix_time::ptime last_sent_
Holds a timestamp when the last message was sent.
void setAggressivity(const int aggressivity)
Sets the value of aggressivity.
void updateSendTime()
Sets the timestamp of the last sent message to current time.
void updateSendDue()
Calculates the send due.
boost::posix_time::ptime send_due_
Holds a timestamp when the next message should be sent.
void setRate(const int rate)
Sets the new rate.
void setRelativeDue(const int offset)
Sets the value of the due time.
int rate_
Holds a desired rate value.
uint64_t getOutboundMessageCount()
Returns number of messages to be sent "now".
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
string currentTime()
Create Time.
Defines the logger used by the top-level component of kea-dhcp-ddns.