diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-05-31 05:46:16 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-05-31 05:46:16 +0000 |
| commit | 1d7b5e6f4ac4137d2d435a7bf3b4b542021e52a9 (patch) | |
| tree | 2d528ed64725e9dd94bd059006499df7e837521b /src/RequestSlot.h | |
| parent | f771b42e537014eb6be0af6c007ca1714b9c5d39 (diff) | |
2008-05-31 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Reduced the usage of gettimeofday().
* src/DefaultBtMessageDispatcher.cc
(DefaultBtMessageDispatcher::checkRequestSlotAndDoNecessaryThing)
(class FindStaleRequestSlot, class ProcessStaleRequestSlot)
* src/RequestSlot.cc
* src/RequestSlot.h
(RequestSlot::isTimeout)
Made RequestSlot have a reference to Piece object to avoid find
Piece repeatedly.
* src/DefaultBtMessageDispatcher.cc
(class FindStaleRequestSlot, class ProcessStaleRequestSlot)
* src/RequestSlot.cc
* src/RequestSlot.h
(RequestSlot::getPiece)
* test/DefaultBtMessageDispatcherTest.cc
Diffstat (limited to 'src/RequestSlot.h')
| -rw-r--r-- | src/RequestSlot.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/RequestSlot.h b/src/RequestSlot.h index 94ab8f8f..8155b899 100644 --- a/src/RequestSlot.h +++ b/src/RequestSlot.h @@ -37,6 +37,7 @@ #include "common.h" #include "TimeA2.h" +#include "Piece.h" #include <deque> namespace aria2 { @@ -48,11 +49,23 @@ private: uint32_t begin; size_t length; size_t blockIndex; + + // This is the piece whose index is index of this RequestSlot has. + // To detect duplicate RequestSlot, we have to find the piece using + // PieceStorage::getPiece() repeatedly. It turns out that this process + // takes time(about 1.7% of processing time). To reduce it, we put piece here + // at the construction of RequestSlot as a cache. + SharedHandle<Piece> _piece; + void copy(const RequestSlot& requestSlot); public: - RequestSlot(size_t index, uint32_t begin, size_t length, size_t blockIndex); + RequestSlot(size_t index, uint32_t begin, size_t length, size_t blockIndex, + const SharedHandle<Piece>& piece = SharedHandle<Piece>()); + RequestSlot(const RequestSlot& requestSlot); + RequestSlot(); + ~RequestSlot() {} RequestSlot& operator=(const RequestSlot& requestSlot); @@ -66,7 +79,7 @@ public: void setDispatchedTime(); void setDispatchedTime(time_t secFromEpoch); - bool isTimeout(time_t timeoutSec) const; + bool isTimeout(const struct timeval& now, time_t timeoutSec) const; unsigned int getLatencyInMillis() const; size_t getIndex() const { return index; } @@ -81,6 +94,8 @@ public: size_t getBlockIndex() const { return blockIndex; } void setBlockIndex(size_t blockIndex) { this->blockIndex = blockIndex; } + SharedHandle<Piece> getPiece() const; + static RequestSlot nullSlot; static bool isNull(const RequestSlot& requestSlot); |
