Skip to content

Commit

Permalink
2010-11-15 Tatsuhiro Tsujikawa <[email protected]>
Browse files Browse the repository at this point in the history
	Use SharedHandle::swap() in some places.
	* src/RequestGroup.cc
  • Loading branch information
tatsuhiro-t committed Nov 15, 2010
1 parent de8598b commit 6a1fe66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2010-11-15 Tatsuhiro Tsujikawa <[email protected]>

Use SharedHandle::swap() in some places.
* src/RequestGroup.cc

2010-11-15 Tatsuhiro Tsujikawa <[email protected]>

Added SharedHandle::swap
Expand Down
35 changes: 19 additions & 16 deletions src/RequestGroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ SharedHandle<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
if(logger_->info()) {
logger_->info(MSG_HASH_CHECK_NOT_DONE);
}
SharedHandle<ChecksumCheckIntegrityEntry> tempEntry
(new ChecksumCheckIntegrityEntry(this));
ChecksumCheckIntegrityEntry* tempEntry =
new ChecksumCheckIntegrityEntry(this);
tempEntry->setRedownload(true);
checkEntry = tempEntry;
checkEntry.reset(tempEntry);
} else
#endif // ENABLE_MESSAGE_DIGEST
{
Expand All @@ -259,10 +259,10 @@ SharedHandle<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
if(option_->getAsBool(PREF_CHECK_INTEGRITY) &&
downloadContext_->isChecksumVerificationAvailable()) {
loadAndOpenFile(infoFile);
SharedHandle<ChecksumCheckIntegrityEntry> tempEntry
(new ChecksumCheckIntegrityEntry(this));
ChecksumCheckIntegrityEntry* tempEntry =
new ChecksumCheckIntegrityEntry(this);
tempEntry->setRedownload(true);
checkEntry = tempEntry;
checkEntry.reset(tempEntry);
} else
#endif // ENABLE_MESSAGE_DIGEST
{
Expand Down Expand Up @@ -590,8 +590,9 @@ void RequestGroup::initPieceStorage()
#endif // ENABLE_BITTORRENT
)) {
#ifdef ENABLE_BITTORRENT
SharedHandle<DefaultPieceStorage> ps
(new DefaultPieceStorage(downloadContext_, option_.get()));
DefaultPieceStorage* ps =
new DefaultPieceStorage(downloadContext_, option_.get());
SharedHandle<PieceStorage> psHolder(ps);
if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
if(isUriSuppliedForRequsetFileEntry
(downloadContext_->getFileEntries().begin(),
Expand Down Expand Up @@ -623,27 +624,29 @@ void RequestGroup::initPieceStorage()
}
}
#else // !ENABLE_BITTORRENT
SharedHandle<DefaultPieceStorage> ps
(new DefaultPieceStorage(downloadContext_, option_.get()));
DefaultPieceStorage* ps =
new DefaultPieceStorage(downloadContext_, option_.get());
SharedHandle<PieceStorage> psHolder(ps);
#endif // !ENABLE_BITTORRENT
if(diskWriterFactory_) {
ps->setDiskWriterFactory(diskWriterFactory_);
}
tempPieceStorage = ps;
tempPieceStorage.swap(psHolder);
} else {
UnknownLengthPieceStorageHandle ps
(new UnknownLengthPieceStorage(downloadContext_, option_.get()));
UnknownLengthPieceStorage* ps =
new UnknownLengthPieceStorage(downloadContext_, option_.get());
SharedHandle<PieceStorage> psHolder(ps);
if(diskWriterFactory_) {
ps->setDiskWriterFactory(diskWriterFactory_);
}
tempPieceStorage = ps;
tempPieceStorage.swap(psHolder);
}
tempPieceStorage->initStorage();
SharedHandle<SegmentMan> tempSegmentMan
(new SegmentMan(option_.get(), downloadContext_, tempPieceStorage));

pieceStorage_ = tempPieceStorage;
segmentMan_ = tempSegmentMan;
pieceStorage_.swap(tempPieceStorage);
segmentMan_.swap(tempSegmentMan);
}

void RequestGroup::dropPieceStorage()
Expand Down

0 comments on commit 6a1fe66

Please sign in to comment.