15 using 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);
81 boost::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");
static boost::posix_time::ptime currentTime()
Convenience function returning current time.
RateControl()
Default constructor.
int getRate() const
Returns the rate.
boost::posix_time::ptime last_sent_
Holds a timestamp when the last message was sent.
void setRelativeDue(const int offset)
Sets the value of the due time.
void updateSendDue()
Calculates the send due.
int aggressivity_
Holds an aggressivity value.
uint64_t getOutboundMessageCount()
Returns number of messages to be sent "now".
void updateSendTime()
Sets the timestamp of the last sent message to current time.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void setRate(const int rate)
Sets the new rate.
bool late_sent_
A flag which indicates that the calculated due time is in the past.
A generic exception that is thrown when an unexpected error condition occurs.
int rate_
Holds a desired rate value.
int getAggressivity() const
Returns the value of aggressivity.
void setAggressivity(const int aggressivity)
Sets the value of aggressivity.
Defines the logger used by the top-level component of kea-dhcp-ddns.
string currentTime()
Create Time.
boost::posix_time::ptime send_due_
Holds a timestamp when the next message should be sent.