Ai
1 Star 0 Fork 0

wangcichen/urbackup_backend

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
PipeThrottler.h 932 Bytes
Copy Edit Raw Blame History
Martin authored 2021-06-20 23:56 +08:00 . Replace std::auto_ptr with std::unique_ptr
#pragma once
#include "Interface/PipeThrottler.h"
#include <memory>
class IMutex;
class PipeThrottler : public IPipeThrottler
{
public:
PipeThrottler(size_t bps, bool percent_max, IPipeThrottlerUpdater* updater);
PipeThrottler();
~PipeThrottler(void);
virtual bool addBytes(size_t new_bytes, bool wait);
virtual void changeThrottleLimit(size_t bps, bool p_percent_max);
virtual void changeThrottleUpdater(IPipeThrottlerUpdater* new_updater);
private:
enum ThrottleState
{
ThrottleState_Probe,
ThrottleState_Throttle
};
size_t throttle_bps;
bool percent_max;
int64 update_time_interval;
size_t curr_bytes;
int64 lastresettime;
int64 lastupdatetime;
std::unique_ptr<IPipeThrottlerUpdater> updater;
ThrottleState throttle_state;
int64 lastprobetime;
float probe_bps;
size_t throttle_percent;
float last_probe_result;
size_t probe_interval;
IMutex *mutex;
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/wangcichen/urbackup_backend.git
git@gitee.com:wangcichen/urbackup_backend.git
wangcichen
urbackup_backend
urbackup_backend
dev

Search