diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-02-10 15:07:06 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-02-10 15:07:06 +0000 |
| commit | ccc552cec90b9e71ca36db763fe2ea95bb2dd2ca (patch) | |
| tree | d1ed3197a5f21abc6eaa644d6dc0ffcef2faf5dd /src/Piece.h | |
| parent | 762580ba8cbcb14734d42b9e8f6a1c16220319f2 (diff) | |
2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added BitfieldMan::getFirstNMissingUnusedIndex() to get multiple
unused block indexes at once instead of calling
getFirstMissingUnusedIndex() multiple times. Made use of it in
Piece class and DefaultBtRequestFactory class via Piece class.
* src/BitfieldMan.cc
* src/BitfieldMan.h
* src/DefaultBtRequestFactory.cc
* src/Piece.cc
* src/Piece.h
* test/BitfieldManTest.cc
Diffstat (limited to 'src/Piece.h')
| -rw-r--r-- | src/Piece.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Piece.h b/src/Piece.h index 4a7b8e93..3177ac89 100644 --- a/src/Piece.h +++ b/src/Piece.h @@ -36,11 +36,14 @@ #define _D_PIECE_H_ #include "common.h" -#include "SharedHandle.h" + #include <stdint.h> #include <deque> +#include <vector> #include <string> +#include "SharedHandle.h" + namespace aria2 { class BitfieldMan; @@ -92,8 +95,15 @@ public: return index < piece.index; } + // TODO This function only used by unit tests bool getMissingUnusedBlockIndex(size_t& index) const; - bool getMissingBlockIndex(size_t& index) const; + + // Stores at most n missing unused block index to indexes. For all i + // in indexes, call bitfield->setUseBit(i). This function just add + // index to indexes and it doesn't remove anything from + // it. Therefore Caller must pass empty indexes. + bool getMissingUnusedBlockIndex(std::vector<size_t>& indexes, size_t n) const; + bool getFirstMissingBlockIndexWithoutLock(size_t& index) const; bool getAllMissingBlockIndexes(unsigned char* misbitfield, size_t mislen) const; |
