mirror of https://github.com/aria2/aria2
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed member variables. * src/PeerStat.hpull/1/head
parent
b3b955b0c4
commit
5daa77b7f9
|
@ -1,3 +1,8 @@
|
||||||
|
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Renamed member variables.
|
||||||
|
* src/PeerStat.h
|
||||||
|
|
||||||
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Renamed member variables.
|
Renamed member variables.
|
||||||
|
|
|
@ -53,13 +53,13 @@ public:
|
||||||
ACTIVE,
|
ACTIVE,
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
cuid_t cuid;
|
cuid_t _cuid;
|
||||||
std::string _hostname;
|
std::string _hostname;
|
||||||
std::string _protocol;
|
std::string _protocol;
|
||||||
SpeedCalc downloadSpeed;
|
SpeedCalc _downloadSpeed;
|
||||||
SpeedCalc uploadSpeed;
|
SpeedCalc _uploadSpeed;
|
||||||
Timer downloadStartTime;
|
Timer _downloadStartTime;
|
||||||
PeerStat::STATUS status;
|
PeerStat::STATUS _status;
|
||||||
unsigned int _avgDownloadSpeed;
|
unsigned int _avgDownloadSpeed;
|
||||||
unsigned int _avgUploadSpeed;
|
unsigned int _avgUploadSpeed;
|
||||||
uint64_t _sessionDownloadLength;
|
uint64_t _sessionDownloadLength;
|
||||||
|
@ -68,17 +68,19 @@ public:
|
||||||
|
|
||||||
PeerStat(cuid_t cuid, const std::string& hostname,
|
PeerStat(cuid_t cuid, const std::string& hostname,
|
||||||
const::std::string& protocol):
|
const::std::string& protocol):
|
||||||
cuid(cuid),
|
_cuid(cuid),
|
||||||
_hostname(hostname),
|
_hostname(hostname),
|
||||||
_protocol(protocol),
|
_protocol(protocol),
|
||||||
downloadStartTime(global::wallclock),
|
_downloadStartTime(global::wallclock),
|
||||||
status(PeerStat::IDLE),
|
_status(PeerStat::IDLE),
|
||||||
_avgDownloadSpeed(0),
|
_avgDownloadSpeed(0),
|
||||||
_avgUploadSpeed(0),
|
_avgUploadSpeed(0),
|
||||||
_sessionDownloadLength(0),
|
_sessionDownloadLength(0),
|
||||||
_sessionUploadLength(0) {}
|
_sessionUploadLength(0) {}
|
||||||
|
|
||||||
PeerStat(cuid_t cuid = 0):cuid(cuid), status(PeerStat::IDLE),
|
PeerStat(cuid_t cuid = 0):
|
||||||
|
_cuid(cuid),
|
||||||
|
_status(PeerStat::IDLE),
|
||||||
_avgDownloadSpeed(0),
|
_avgDownloadSpeed(0),
|
||||||
_avgUploadSpeed(0),
|
_avgUploadSpeed(0),
|
||||||
_sessionDownloadLength(0),
|
_sessionDownloadLength(0),
|
||||||
|
@ -88,39 +90,39 @@ public:
|
||||||
* Returns current download speed in byte per sec.
|
* Returns current download speed in byte per sec.
|
||||||
*/
|
*/
|
||||||
unsigned int calculateDownloadSpeed() {
|
unsigned int calculateDownloadSpeed() {
|
||||||
return downloadSpeed.calculateSpeed();
|
return _downloadSpeed.calculateSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculateAvgDownloadSpeed() {
|
unsigned int calculateAvgDownloadSpeed() {
|
||||||
_avgDownloadSpeed = downloadSpeed.calculateAvgSpeed();
|
_avgDownloadSpeed = _downloadSpeed.calculateAvgSpeed();
|
||||||
return _avgDownloadSpeed;
|
return _avgDownloadSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculateUploadSpeed() {
|
unsigned int calculateUploadSpeed() {
|
||||||
return uploadSpeed.calculateSpeed();
|
return _uploadSpeed.calculateSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculateAvgUploadSpeed() {
|
unsigned int calculateAvgUploadSpeed() {
|
||||||
_avgUploadSpeed = uploadSpeed.calculateAvgSpeed();
|
_avgUploadSpeed = _uploadSpeed.calculateAvgSpeed();
|
||||||
return _avgUploadSpeed;
|
return _avgUploadSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateDownloadLength(size_t bytes) {
|
void updateDownloadLength(size_t bytes) {
|
||||||
downloadSpeed.update(bytes);
|
_downloadSpeed.update(bytes);
|
||||||
_sessionDownloadLength += bytes;
|
_sessionDownloadLength += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateUploadLength(size_t bytes) {
|
void updateUploadLength(size_t bytes) {
|
||||||
uploadSpeed.update(bytes);
|
_uploadSpeed.update(bytes);
|
||||||
_sessionUploadLength += bytes;
|
_sessionUploadLength += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getMaxDownloadSpeed() const {
|
unsigned int getMaxDownloadSpeed() const {
|
||||||
return downloadSpeed.getMaxSpeed();
|
return _downloadSpeed.getMaxSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getMaxUploadSpeed() const {
|
unsigned int getMaxUploadSpeed() const {
|
||||||
return uploadSpeed.getMaxSpeed();
|
return _uploadSpeed.getMaxSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getAvgDownloadSpeed() const {
|
unsigned int getAvgDownloadSpeed() const {
|
||||||
|
@ -132,33 +134,33 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
downloadSpeed.reset();
|
_downloadSpeed.reset();
|
||||||
uploadSpeed.reset();
|
_uploadSpeed.reset();
|
||||||
downloadStartTime = global::wallclock;
|
_downloadStartTime = global::wallclock;
|
||||||
status = PeerStat::IDLE;
|
_status = PeerStat::IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void downloadStart() {
|
void downloadStart() {
|
||||||
reset();
|
reset();
|
||||||
status = PeerStat::ACTIVE;
|
_status = PeerStat::ACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void downloadStop() {
|
void downloadStop() {
|
||||||
calculateAvgDownloadSpeed();
|
calculateAvgDownloadSpeed();
|
||||||
calculateAvgUploadSpeed();
|
calculateAvgUploadSpeed();
|
||||||
status = PeerStat::IDLE;
|
_status = PeerStat::IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Timer& getDownloadStartTime() const {
|
const Timer& getDownloadStartTime() const {
|
||||||
return downloadStartTime;
|
return _downloadStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerStat::STATUS getStatus() const {
|
PeerStat::STATUS getStatus() const {
|
||||||
return status;
|
return _status;
|
||||||
}
|
}
|
||||||
|
|
||||||
cuid_t getCuid() const {
|
cuid_t getCuid() const {
|
||||||
return cuid;
|
return _cuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& getHostname() const
|
const std::string& getHostname() const
|
||||||
|
|
Loading…
Reference in New Issue