mirror of https://github.com/aria2/aria2
2008-05-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed method signature: MultiFileAllocationIterator::makeDiskWriterEntries * src/MultiFileAllocationIterator.cc * src/MultiFileAllocationIterator.hpull/1/head
parent
3da60af41e
commit
6ae07106d3
|
@ -1,3 +1,10 @@
|
||||||
|
2008-05-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Changed method signature:
|
||||||
|
MultiFileAllocationIterator::makeDiskWriterEntries
|
||||||
|
* src/MultiFileAllocationIterator.cc
|
||||||
|
* src/MultiFileAllocationIterator.h
|
||||||
|
|
||||||
2008-05-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-05-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Changed method sinature:
|
Changed method sinature:
|
||||||
|
|
|
@ -42,10 +42,11 @@ namespace aria2 {
|
||||||
|
|
||||||
MultiFileAllocationIterator::MultiFileAllocationIterator(MultiDiskAdaptor* diskAdaptor):
|
MultiFileAllocationIterator::MultiFileAllocationIterator(MultiDiskAdaptor* diskAdaptor):
|
||||||
_diskAdaptor(diskAdaptor),
|
_diskAdaptor(diskAdaptor),
|
||||||
_entries(makeDiskWriterEntries(diskAdaptor->diskWriterEntries,
|
|
||||||
diskAdaptor->getPieceLength())),
|
|
||||||
_offset(0)
|
_offset(0)
|
||||||
{}
|
{
|
||||||
|
makeDiskWriterEntries(_entries, diskAdaptor->diskWriterEntries,
|
||||||
|
diskAdaptor->getPieceLength());
|
||||||
|
}
|
||||||
|
|
||||||
MultiFileAllocationIterator::~MultiFileAllocationIterator() {}
|
MultiFileAllocationIterator::~MultiFileAllocationIterator() {}
|
||||||
|
|
||||||
|
@ -101,24 +102,23 @@ const DiskWriterEntries& MultiFileAllocationIterator::getDiskWriterEntries() con
|
||||||
return _entries;
|
return _entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskWriterEntries MultiFileAllocationIterator::makeDiskWriterEntries(const DiskWriterEntries& srcEntries, size_t pieceLength) const
|
void MultiFileAllocationIterator::makeDiskWriterEntries
|
||||||
|
(std::deque<SharedHandle<DiskWriterEntry> >& dwEntries,
|
||||||
|
const DiskWriterEntries& srcEntries, size_t pieceLength) const
|
||||||
{
|
{
|
||||||
if(pieceLength == 0) {
|
if(pieceLength == 0) {
|
||||||
DiskWriterEntries entries;
|
|
||||||
for(DiskWriterEntries::const_iterator itr = srcEntries.begin(); itr != srcEntries.end(); ++itr) {
|
for(DiskWriterEntries::const_iterator itr = srcEntries.begin(); itr != srcEntries.end(); ++itr) {
|
||||||
if((*itr)->getFileEntry()->isRequested()) {
|
if((*itr)->getFileEntry()->isRequested()) {
|
||||||
entries.push_back(*itr);
|
dwEntries.push_back(*itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entries;
|
} else {
|
||||||
}
|
|
||||||
DiskWriterEntries temp(srcEntries);
|
DiskWriterEntries temp(srcEntries);
|
||||||
{
|
{
|
||||||
SharedHandle<FileEntry> f(new FileEntry());
|
SharedHandle<FileEntry> f(new FileEntry());
|
||||||
SharedHandle<DiskWriterEntry> e(new DiskWriterEntry(f));
|
SharedHandle<DiskWriterEntry> e(new DiskWriterEntry(f));
|
||||||
temp.push_front(e);
|
temp.push_front(e);
|
||||||
}
|
}
|
||||||
DiskWriterEntries entries;
|
|
||||||
DiskWriterEntries::const_iterator done = temp.begin();
|
DiskWriterEntries::const_iterator done = temp.begin();
|
||||||
for(DiskWriterEntries::const_iterator itr = temp.begin()+1; itr != temp.end(); ++itr) {
|
for(DiskWriterEntries::const_iterator itr = temp.begin()+1; itr != temp.end(); ++itr) {
|
||||||
const FileEntryHandle& fileEntry = (*itr)->getFileEntry();
|
const FileEntryHandle& fileEntry = (*itr)->getFileEntry();
|
||||||
|
@ -128,15 +128,15 @@ DiskWriterEntries MultiFileAllocationIterator::makeDiskWriterEntries(const DiskW
|
||||||
off_t pieceStartOffset = (fileEntry->getOffset()/pieceLength)*pieceLength;
|
off_t pieceStartOffset = (fileEntry->getOffset()/pieceLength)*pieceLength;
|
||||||
for(DiskWriterEntries::const_iterator i = itr-1; i != done; --i) {
|
for(DiskWriterEntries::const_iterator i = itr-1; i != done; --i) {
|
||||||
if((uint64_t)pieceStartOffset < (*i)->getFileEntry()->getOffset()+(*i)->getFileEntry()->getLength()) {
|
if((uint64_t)pieceStartOffset < (*i)->getFileEntry()->getOffset()+(*i)->getFileEntry()->getLength()) {
|
||||||
entries.push_back(*i);
|
dwEntries.push_back(*i);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entries.push_back(*itr);
|
dwEntries.push_back(*itr);
|
||||||
done = itr;
|
done = itr;
|
||||||
}
|
}
|
||||||
return entries;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -52,8 +52,9 @@ private:
|
||||||
SharedHandle<SingleFileAllocationIterator> _fileAllocationIterator;
|
SharedHandle<SingleFileAllocationIterator> _fileAllocationIterator;
|
||||||
off_t _offset;
|
off_t _offset;
|
||||||
|
|
||||||
std::deque<SharedHandle<DiskWriterEntry> >
|
void makeDiskWriterEntries
|
||||||
makeDiskWriterEntries(const std::deque<SharedHandle<DiskWriterEntry> >& srcEntries,
|
(std::deque<SharedHandle<DiskWriterEntry> >& dwEntries,
|
||||||
|
const std::deque<SharedHandle<DiskWriterEntry> >& srcEntries,
|
||||||
size_t pieceLength) const;
|
size_t pieceLength) const;
|
||||||
public:
|
public:
|
||||||
MultiFileAllocationIterator(MultiDiskAdaptor* diskAdaptor);
|
MultiFileAllocationIterator(MultiDiskAdaptor* diskAdaptor);
|
||||||
|
|
Loading…
Reference in New Issue