1 #include <LibCyberRadio/Common/Throttle.hpp> 3 Throttle::Throttle(
double sample_rate)
5 this->sample_rate = sample_rate;
6 this->target_rate = (double)(sample_rate) * (4136/1024);
7 this->target_rate /= (1024*1024);
8 std::chrono::system_clock clock;
10 this->start_time = clock.now();
13 void Throttle::throttle(
unsigned int bytes_sent)
15 this->MB_sent += ((double)bytes_sent)/(1048576);
16 std::chrono::time_point<std::chrono::system_clock,std::chrono::nanoseconds> curr_time = this->clock.now();
17 std::chrono::duration<double> elapsed = curr_time - start_time;
18 double current_rate = ((this->MB_sent)) / (elapsed.count());
20 if (current_rate > this->target_rate) {