mirror of https://github.com/aria2/aria2
2009-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Replaced FileAllocationMan with SequentialPicker<FileAllocationEntry>. * src/BtCheckIntegrityEntry.cc * src/ConsoleStatCalc.cc * src/DownloadEngine.cc * src/DownloadEngine.h * src/DownloadEngineFactory.cc * src/FileAllocationCommand.cc * src/FileAllocationDispatcherCommand.cc * src/FileAllocationMan.h * src/Makefile.am * src/SequentialPicker.h * src/StatCalc.h * src/StreamCheckIntegrityEntry.cc * test/Makefile.am * test/SequentialPickerTest.ccpull/1/head
parent
ea370b864e
commit
8ca9db9f3e
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
||||||
|
2009-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Replaced FileAllocationMan with
|
||||||
|
SequentialPicker<FileAllocationEntry>.
|
||||||
|
* src/BtCheckIntegrityEntry.cc
|
||||||
|
* src/ConsoleStatCalc.cc
|
||||||
|
* src/DownloadEngine.cc
|
||||||
|
* src/DownloadEngine.h
|
||||||
|
* src/DownloadEngineFactory.cc
|
||||||
|
* src/FileAllocationCommand.cc
|
||||||
|
* src/FileAllocationDispatcherCommand.cc
|
||||||
|
* src/FileAllocationMan.h
|
||||||
|
* src/Makefile.am
|
||||||
|
* src/SequentialPicker.h
|
||||||
|
* src/StatCalc.h
|
||||||
|
* src/StreamCheckIntegrityEntry.cc
|
||||||
|
* test/Makefile.am
|
||||||
|
* test/SequentialPickerTest.cc
|
||||||
|
|
||||||
2009-01-19 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-01-19 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added doc for adaptive URI selector.
|
Added doc for adaptive URI selector.
|
||||||
|
|
|
@ -54,7 +54,7 @@ void BtCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& commands,
|
||||||
{
|
{
|
||||||
FileAllocationEntryHandle entry(new BtFileAllocationEntry(_requestGroup));
|
FileAllocationEntryHandle entry(new BtFileAllocationEntry(_requestGroup));
|
||||||
if(_requestGroup->needsFileAllocation()) {
|
if(_requestGroup->needsFileAllocation()) {
|
||||||
e->_fileAllocationMan->pushFileAllocationEntry(entry);
|
e->_fileAllocationMan->pushEntry(entry);
|
||||||
} else {
|
} else {
|
||||||
entry->prepareForNextAction(commands, e);
|
entry->prepareForNextAction(commands, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,9 +162,10 @@ ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval):
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConsoleStatCalc::calculateStat(const RequestGroupManHandle& requestGroupMan,
|
ConsoleStatCalc::calculateStat
|
||||||
const FileAllocationManHandle& fileAllocationMan,
|
(const RequestGroupManHandle& requestGroupMan,
|
||||||
const CheckIntegrityManHandle& checkIntegrityMan)
|
const SharedHandle<FileAllocationMan>& fileAllocationMan,
|
||||||
|
const CheckIntegrityManHandle& checkIntegrityMan)
|
||||||
{
|
{
|
||||||
if(!_cp.elapsed(1)) {
|
if(!_cp.elapsed(1)) {
|
||||||
return;
|
return;
|
||||||
|
@ -211,7 +212,7 @@ ConsoleStatCalc::calculateStat(const RequestGroupManHandle& requestGroupMan,
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
FileAllocationEntryHandle entry = fileAllocationMan->getCurrentFileAllocationEntry();
|
SharedHandle<FileAllocationEntry> entry=fileAllocationMan->getPickedEntry();
|
||||||
if(!entry.isNull()) {
|
if(!entry.isNull()) {
|
||||||
o << " "
|
o << " "
|
||||||
<< "[FileAlloc:"
|
<< "[FileAlloc:"
|
||||||
|
@ -229,9 +230,9 @@ ConsoleStatCalc::calculateStat(const RequestGroupManHandle& requestGroupMan,
|
||||||
}
|
}
|
||||||
o << "%)"
|
o << "%)"
|
||||||
<< "]";
|
<< "]";
|
||||||
if(fileAllocationMan->countFileAllocationEntryInQueue() > 0) {
|
if(fileAllocationMan->hasNext()) {
|
||||||
o << "("
|
o << "("
|
||||||
<< fileAllocationMan->countFileAllocationEntryInQueue()
|
<< fileAllocationMan->countEntryInQueue()
|
||||||
<< "waiting...)";
|
<< "waiting...)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "StatCalc.h"
|
#include "StatCalc.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "FileAllocationMan.h"
|
|
||||||
#include "CheckIntegrityMan.h"
|
#include "CheckIntegrityMan.h"
|
||||||
#include "DownloadResult.h"
|
#include "DownloadResult.h"
|
||||||
#include "StatCalc.h"
|
#include "StatCalc.h"
|
||||||
|
@ -65,6 +64,7 @@
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "EventPoll.h"
|
#include "EventPoll.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
|
||||||
#include "BtRegistry.h"
|
#include "BtRegistry.h"
|
||||||
#include "BtContext.h"
|
#include "BtContext.h"
|
||||||
|
|
|
@ -49,13 +49,13 @@
|
||||||
# include "AsyncNameResolver.h"
|
# include "AsyncNameResolver.h"
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
#include "CUIDCounter.h"
|
#include "CUIDCounter.h"
|
||||||
|
#include "FileAllocationMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class Logger;
|
class Logger;
|
||||||
class Option;
|
class Option;
|
||||||
class RequestGroupMan;
|
class RequestGroupMan;
|
||||||
class FileAllocationMan;
|
|
||||||
class StatCalc;
|
class StatCalc;
|
||||||
class CheckIntegrityMan;
|
class CheckIntegrityMan;
|
||||||
class SocketCore;
|
class SocketCore;
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
#endif // HAVE_EPOLL
|
#endif // HAVE_EPOLL
|
||||||
#include "SelectEventPoll.h"
|
#include "SelectEventPoll.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool FileAllocationCommand::executeInternal()
|
||||||
logger->debug(MSG_ALLOCATION_COMPLETED,
|
logger->debug(MSG_ALLOCATION_COMPLETED,
|
||||||
_timer.difference(),
|
_timer.difference(),
|
||||||
Util::itos(_requestGroup->getTotalLength(), true).c_str());
|
Util::itos(_requestGroup->getTotalLength(), true).c_str());
|
||||||
_e->_fileAllocationMan->markCurrentFileAllocationEntryDone();
|
_e->_fileAllocationMan->dropPickedEntry();
|
||||||
|
|
||||||
std::deque<Command*> commands;
|
std::deque<Command*> commands;
|
||||||
_fileAllocationEntry->prepareForNextAction(commands, _e);
|
_fileAllocationEntry->prepareForNextAction(commands, _e);
|
||||||
|
@ -75,7 +75,7 @@ bool FileAllocationCommand::executeInternal()
|
||||||
|
|
||||||
bool FileAllocationCommand::handleException(Exception& e)
|
bool FileAllocationCommand::handleException(Exception& e)
|
||||||
{
|
{
|
||||||
_e->_fileAllocationMan->markCurrentFileAllocationEntryDone();
|
_e->_fileAllocationMan->dropPickedEntry();
|
||||||
logger->error(MSG_FILE_ALLOCATION_FAILURE, e, cuid);
|
logger->error(MSG_FILE_ALLOCATION_FAILURE, e, cuid);
|
||||||
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str());
|
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -56,9 +56,8 @@ bool FileAllocationDispatcherCommand::execute()
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(_e->_fileAllocationMan->nextFileAllocationEntryExists() &&
|
if(_e->_fileAllocationMan->hasNext() && !_e->_fileAllocationMan->isPicked()) {
|
||||||
!_e->_fileAllocationMan->isFileAllocationBeingExecuted()) {
|
FileAllocationEntryHandle entry = _e->_fileAllocationMan->pickNext();
|
||||||
FileAllocationEntryHandle entry = _e->_fileAllocationMan->popNextFileAllocationEntry();
|
|
||||||
int32_t newCUID = _e->newCUID();
|
int32_t newCUID = _e->newCUID();
|
||||||
logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID);
|
logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID);
|
||||||
FileAllocationCommand* command =
|
FileAllocationCommand* command =
|
||||||
|
|
|
@ -36,38 +36,13 @@
|
||||||
#define _D_FILE_ALLOCATION_MAN_H_
|
#define _D_FILE_ALLOCATION_MAN_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SequentialPicker.h"
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class FileAllocationEntry;
|
class FileAllocationEntry;
|
||||||
|
|
||||||
class FileAllocationMan {
|
typedef SequentialPicker<FileAllocationEntry> FileAllocationMan;
|
||||||
private:
|
|
||||||
std::deque<SharedHandle<FileAllocationEntry> > _fileAllocationEntries;
|
|
||||||
SharedHandle<FileAllocationEntry> _currentFileAllocationEntry;
|
|
||||||
public:
|
|
||||||
FileAllocationMan();
|
|
||||||
|
|
||||||
~FileAllocationMan();
|
|
||||||
|
|
||||||
bool isFileAllocationBeingExecuted() const;
|
|
||||||
|
|
||||||
SharedHandle<FileAllocationEntry> getCurrentFileAllocationEntry();
|
|
||||||
|
|
||||||
void markCurrentFileAllocationEntryDone();
|
|
||||||
|
|
||||||
bool nextFileAllocationEntryExists() const;
|
|
||||||
|
|
||||||
SharedHandle<FileAllocationEntry> popNextFileAllocationEntry();
|
|
||||||
|
|
||||||
void pushFileAllocationEntry(const SharedHandle<FileAllocationEntry>& entry);
|
|
||||||
|
|
||||||
size_t countFileAllocationEntryInQueue() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef SharedHandle<FileAllocationMan> FileAllocationManHandle;
|
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ SRCS = Socket.h\
|
||||||
RequestGroup.cc RequestGroup.h\
|
RequestGroup.cc RequestGroup.h\
|
||||||
RequestGroupAware.cc RequestGroupAware.h\
|
RequestGroupAware.cc RequestGroupAware.h\
|
||||||
RequestGroupMan.cc RequestGroupMan.h\
|
RequestGroupMan.cc RequestGroupMan.h\
|
||||||
FileAllocationMan.cc FileAllocationMan.h\
|
FileAllocationMan.h\
|
||||||
FileAllocationCommand.cc FileAllocationCommand.h\
|
FileAllocationCommand.cc FileAllocationCommand.h\
|
||||||
FillRequestGroupCommand.cc FillRequestGroupCommand.h\
|
FillRequestGroupCommand.cc FillRequestGroupCommand.h\
|
||||||
FileAllocationDispatcherCommand.cc FileAllocationDispatcherCommand.h\
|
FileAllocationDispatcherCommand.cc FileAllocationDispatcherCommand.h\
|
||||||
|
@ -198,7 +198,8 @@ SRCS = Socket.h\
|
||||||
bencode.cc bencode.h\
|
bencode.cc bencode.h\
|
||||||
URIResult.cc URIResult.h\
|
URIResult.cc URIResult.h\
|
||||||
EventPoll.h\
|
EventPoll.h\
|
||||||
SelectEventPoll.cc SelectEventPoll.h
|
SelectEventPoll.cc SelectEventPoll.h\
|
||||||
|
SequentialPicker.h
|
||||||
|
|
||||||
if HAVE_EPOLL
|
if HAVE_EPOLL
|
||||||
SRCS += EpollEventPoll.cc EpollEventPoll.h
|
SRCS += EpollEventPoll.cc EpollEventPoll.h
|
||||||
|
|
|
@ -341,10 +341,9 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
|
||||||
NameMatchOptionHandler.h NameResolver.cc NameResolver.h \
|
NameMatchOptionHandler.h NameResolver.cc NameResolver.h \
|
||||||
RequestGroup.cc RequestGroup.h RequestGroupAware.cc \
|
RequestGroup.cc RequestGroup.h RequestGroupAware.cc \
|
||||||
RequestGroupAware.h RequestGroupMan.cc RequestGroupMan.h \
|
RequestGroupAware.h RequestGroupMan.cc RequestGroupMan.h \
|
||||||
FileAllocationMan.cc FileAllocationMan.h \
|
FileAllocationMan.h FileAllocationCommand.cc \
|
||||||
FileAllocationCommand.cc FileAllocationCommand.h \
|
FileAllocationCommand.h FillRequestGroupCommand.cc \
|
||||||
FillRequestGroupCommand.cc FillRequestGroupCommand.h \
|
FillRequestGroupCommand.h FileAllocationDispatcherCommand.cc \
|
||||||
FileAllocationDispatcherCommand.cc \
|
|
||||||
FileAllocationDispatcherCommand.h FileAllocationEntry.cc \
|
FileAllocationDispatcherCommand.h FileAllocationEntry.cc \
|
||||||
FileAllocationEntry.h StreamFileAllocationEntry.cc \
|
FileAllocationEntry.h StreamFileAllocationEntry.cc \
|
||||||
StreamFileAllocationEntry.h MultiUrlRequestInfo.cc \
|
StreamFileAllocationEntry.h MultiUrlRequestInfo.cc \
|
||||||
|
@ -414,8 +413,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
|
||||||
SocketBuffer.h OptionHandlerException.cc \
|
SocketBuffer.h OptionHandlerException.cc \
|
||||||
OptionHandlerException.h bencode.cc bencode.h URIResult.cc \
|
OptionHandlerException.h bencode.cc bencode.h URIResult.cc \
|
||||||
URIResult.h EventPoll.h SelectEventPoll.cc SelectEventPoll.h \
|
URIResult.h EventPoll.h SelectEventPoll.cc SelectEventPoll.h \
|
||||||
EpollEventPoll.cc EpollEventPoll.h TLSContext.h \
|
SequentialPicker.h EpollEventPoll.cc EpollEventPoll.h \
|
||||||
LibgnutlsTLSContext.cc LibgnutlsTLSContext.h \
|
TLSContext.h LibgnutlsTLSContext.cc LibgnutlsTLSContext.h \
|
||||||
LibsslTLSContext.cc LibsslTLSContext.h GZipDecoder.cc \
|
LibsslTLSContext.cc LibsslTLSContext.h GZipDecoder.cc \
|
||||||
GZipDecoder.h Sqlite3MozCookieParser.cc \
|
GZipDecoder.h Sqlite3MozCookieParser.cc \
|
||||||
Sqlite3MozCookieParser.h AsyncNameResolver.cc \
|
Sqlite3MozCookieParser.h AsyncNameResolver.cc \
|
||||||
|
@ -764,7 +763,7 @@ am__objects_22 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
|
||||||
OptionHandlerFactory.$(OBJEXT) OptionHandler.$(OBJEXT) \
|
OptionHandlerFactory.$(OBJEXT) OptionHandler.$(OBJEXT) \
|
||||||
NameResolver.$(OBJEXT) RequestGroup.$(OBJEXT) \
|
NameResolver.$(OBJEXT) RequestGroup.$(OBJEXT) \
|
||||||
RequestGroupAware.$(OBJEXT) RequestGroupMan.$(OBJEXT) \
|
RequestGroupAware.$(OBJEXT) RequestGroupMan.$(OBJEXT) \
|
||||||
FileAllocationMan.$(OBJEXT) FileAllocationCommand.$(OBJEXT) \
|
FileAllocationCommand.$(OBJEXT) \
|
||||||
FillRequestGroupCommand.$(OBJEXT) \
|
FillRequestGroupCommand.$(OBJEXT) \
|
||||||
FileAllocationDispatcherCommand.$(OBJEXT) \
|
FileAllocationDispatcherCommand.$(OBJEXT) \
|
||||||
FileAllocationEntry.$(OBJEXT) \
|
FileAllocationEntry.$(OBJEXT) \
|
||||||
|
@ -1068,10 +1067,9 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
|
||||||
NameMatchOptionHandler.h NameResolver.cc NameResolver.h \
|
NameMatchOptionHandler.h NameResolver.cc NameResolver.h \
|
||||||
RequestGroup.cc RequestGroup.h RequestGroupAware.cc \
|
RequestGroup.cc RequestGroup.h RequestGroupAware.cc \
|
||||||
RequestGroupAware.h RequestGroupMan.cc RequestGroupMan.h \
|
RequestGroupAware.h RequestGroupMan.cc RequestGroupMan.h \
|
||||||
FileAllocationMan.cc FileAllocationMan.h \
|
FileAllocationMan.h FileAllocationCommand.cc \
|
||||||
FileAllocationCommand.cc FileAllocationCommand.h \
|
FileAllocationCommand.h FillRequestGroupCommand.cc \
|
||||||
FillRequestGroupCommand.cc FillRequestGroupCommand.h \
|
FillRequestGroupCommand.h FileAllocationDispatcherCommand.cc \
|
||||||
FileAllocationDispatcherCommand.cc \
|
|
||||||
FileAllocationDispatcherCommand.h FileAllocationEntry.cc \
|
FileAllocationDispatcherCommand.h FileAllocationEntry.cc \
|
||||||
FileAllocationEntry.h StreamFileAllocationEntry.cc \
|
FileAllocationEntry.h StreamFileAllocationEntry.cc \
|
||||||
StreamFileAllocationEntry.h MultiUrlRequestInfo.cc \
|
StreamFileAllocationEntry.h MultiUrlRequestInfo.cc \
|
||||||
|
@ -1141,13 +1139,14 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
|
||||||
SocketBuffer.h OptionHandlerException.cc \
|
SocketBuffer.h OptionHandlerException.cc \
|
||||||
OptionHandlerException.h bencode.cc bencode.h URIResult.cc \
|
OptionHandlerException.h bencode.cc bencode.h URIResult.cc \
|
||||||
URIResult.h EventPoll.h SelectEventPoll.cc SelectEventPoll.h \
|
URIResult.h EventPoll.h SelectEventPoll.cc SelectEventPoll.h \
|
||||||
$(am__append_1) $(am__append_2) $(am__append_3) \
|
SequentialPicker.h $(am__append_1) $(am__append_2) \
|
||||||
$(am__append_4) $(am__append_5) $(am__append_6) \
|
$(am__append_3) $(am__append_4) $(am__append_5) \
|
||||||
$(am__append_7) $(am__append_8) $(am__append_9) \
|
$(am__append_6) $(am__append_7) $(am__append_8) \
|
||||||
$(am__append_10) $(am__append_11) $(am__append_12) \
|
$(am__append_9) $(am__append_10) $(am__append_11) \
|
||||||
$(am__append_13) $(am__append_14) $(am__append_15) \
|
$(am__append_12) $(am__append_13) $(am__append_14) \
|
||||||
$(am__append_16) $(am__append_17) $(am__append_18) \
|
$(am__append_15) $(am__append_16) $(am__append_17) \
|
||||||
$(am__append_19) $(am__append_20) $(am__append_21)
|
$(am__append_18) $(am__append_19) $(am__append_20) \
|
||||||
|
$(am__append_21)
|
||||||
noinst_LIBRARIES = libaria2c.a
|
noinst_LIBRARIES = libaria2c.a
|
||||||
libaria2c_a_SOURCES = $(SRCS)
|
libaria2c_a_SOURCES = $(SRCS)
|
||||||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
||||||
|
@ -1382,7 +1381,6 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationDispatcherCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationDispatcherCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationEntry.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationEntry.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileAllocationMan.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileEntry.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileEntry.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileMetalinkParserState.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileMetalinkParserState.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilesMetalinkParserState.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilesMetalinkParserState.Po@am__quote@
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#ifndef _D_SEQUENTIAL_PICKER_H_
|
||||||
|
#define _D_SEQUENTIAL_PICKER_H_
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
#include "SharedHandle.h"
|
||||||
|
|
||||||
|
namespace aria2 {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class SequentialPicker {
|
||||||
|
private:
|
||||||
|
std::deque<SharedHandle<T> > _entries;
|
||||||
|
SharedHandle<T> _pickedEntry;
|
||||||
|
public:
|
||||||
|
bool isPicked() const
|
||||||
|
{
|
||||||
|
return !_pickedEntry.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedHandle<T> getPickedEntry() const
|
||||||
|
{
|
||||||
|
return _pickedEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dropPickedEntry()
|
||||||
|
{
|
||||||
|
_pickedEntry.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasNext() const
|
||||||
|
{
|
||||||
|
return !_entries.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedHandle<T> pickNext()
|
||||||
|
{
|
||||||
|
SharedHandle<T> r;
|
||||||
|
if(hasNext()) {
|
||||||
|
r = _entries.front();
|
||||||
|
_entries.pop_front();
|
||||||
|
_pickedEntry = r;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pushEntry(const SharedHandle<T>& entry)
|
||||||
|
{
|
||||||
|
_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t countEntryInQueue() const
|
||||||
|
{
|
||||||
|
return _entries.size();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace aria2
|
||||||
|
|
||||||
|
#endif // _D_SEQUENTIAL_PICKER_H_
|
|
@ -37,11 +37,11 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
|
#include "FileAllocationMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class RequestGroupMan;
|
class RequestGroupMan;
|
||||||
class FileAllocationMan;
|
|
||||||
class CheckIntegrityMan;
|
class CheckIntegrityMan;
|
||||||
|
|
||||||
class StatCalc {
|
class StatCalc {
|
||||||
|
|
|
@ -57,7 +57,7 @@ void StreamCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& comma
|
||||||
(new StreamFileAllocationEntry(_currentRequest, _requestGroup,
|
(new StreamFileAllocationEntry(_currentRequest, _requestGroup,
|
||||||
popNextCommand()));
|
popNextCommand()));
|
||||||
if(_requestGroup->needsFileAllocation()) {
|
if(_requestGroup->needsFileAllocation()) {
|
||||||
e->_fileAllocationMan->pushFileAllocationEntry(entry);
|
e->_fileAllocationMan->pushEntry(entry);
|
||||||
} else {
|
} else {
|
||||||
entry->prepareForNextAction(commands, e);
|
entry->prepareForNextAction(commands, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,8 @@ aria2c_SOURCES = AllTest.cc\
|
||||||
OptionParserTest.cc\
|
OptionParserTest.cc\
|
||||||
SimpleDNSCacheTest.cc\
|
SimpleDNSCacheTest.cc\
|
||||||
DownloadHelperTest.cc\
|
DownloadHelperTest.cc\
|
||||||
BencodeTest.cc
|
BencodeTest.cc\
|
||||||
|
SequentialPickerTest.cc
|
||||||
|
|
||||||
if HAVE_LIBZ
|
if HAVE_LIBZ
|
||||||
aria2c_SOURCES += GZipDecoderTest.cc
|
aria2c_SOURCES += GZipDecoderTest.cc
|
||||||
|
|
|
@ -192,8 +192,9 @@ am__aria2c_SOURCES_DIST = AllTest.cc TestUtil.cc TestUtil.h \
|
||||||
DirectDiskAdaptorTest.cc CookieTest.cc CookieStorageTest.cc \
|
DirectDiskAdaptorTest.cc CookieTest.cc CookieStorageTest.cc \
|
||||||
TimeTest.cc CopyDiskAdaptorTest.cc FtpConnectionTest.cc \
|
TimeTest.cc CopyDiskAdaptorTest.cc FtpConnectionTest.cc \
|
||||||
OptionParserTest.cc SimpleDNSCacheTest.cc \
|
OptionParserTest.cc SimpleDNSCacheTest.cc \
|
||||||
DownloadHelperTest.cc BencodeTest.cc GZipDecoderTest.cc \
|
DownloadHelperTest.cc BencodeTest.cc SequentialPickerTest.cc \
|
||||||
Sqlite3MozCookieParserTest.cc MessageDigestHelperTest.cc \
|
GZipDecoderTest.cc Sqlite3MozCookieParserTest.cc \
|
||||||
|
MessageDigestHelperTest.cc \
|
||||||
IteratableChunkChecksumValidatorTest.cc \
|
IteratableChunkChecksumValidatorTest.cc \
|
||||||
IteratableChecksumValidatorTest.cc BtAllowedFastMessageTest.cc \
|
IteratableChecksumValidatorTest.cc BtAllowedFastMessageTest.cc \
|
||||||
BtBitfieldMessageTest.cc BtCancelMessageTest.cc \
|
BtBitfieldMessageTest.cc BtCancelMessageTest.cc \
|
||||||
|
@ -360,8 +361,9 @@ am_aria2c_OBJECTS = AllTest.$(OBJEXT) TestUtil.$(OBJEXT) \
|
||||||
TimeTest.$(OBJEXT) CopyDiskAdaptorTest.$(OBJEXT) \
|
TimeTest.$(OBJEXT) CopyDiskAdaptorTest.$(OBJEXT) \
|
||||||
FtpConnectionTest.$(OBJEXT) OptionParserTest.$(OBJEXT) \
|
FtpConnectionTest.$(OBJEXT) OptionParserTest.$(OBJEXT) \
|
||||||
SimpleDNSCacheTest.$(OBJEXT) DownloadHelperTest.$(OBJEXT) \
|
SimpleDNSCacheTest.$(OBJEXT) DownloadHelperTest.$(OBJEXT) \
|
||||||
BencodeTest.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
|
BencodeTest.$(OBJEXT) SequentialPickerTest.$(OBJEXT) \
|
||||||
$(am__objects_3) $(am__objects_4) $(am__objects_5)
|
$(am__objects_1) $(am__objects_2) $(am__objects_3) \
|
||||||
|
$(am__objects_4) $(am__objects_5)
|
||||||
aria2c_OBJECTS = $(am_aria2c_OBJECTS)
|
aria2c_OBJECTS = $(am_aria2c_OBJECTS)
|
||||||
am__DEPENDENCIES_1 =
|
am__DEPENDENCIES_1 =
|
||||||
aria2c_DEPENDENCIES = ../src/libaria2c.a ../src/download_helper.o \
|
aria2c_DEPENDENCIES = ../src/libaria2c.a ../src/download_helper.o \
|
||||||
|
@ -584,9 +586,9 @@ aria2c_SOURCES = AllTest.cc TestUtil.cc TestUtil.h SocketCoreTest.cc \
|
||||||
DirectDiskAdaptorTest.cc CookieTest.cc CookieStorageTest.cc \
|
DirectDiskAdaptorTest.cc CookieTest.cc CookieStorageTest.cc \
|
||||||
TimeTest.cc CopyDiskAdaptorTest.cc FtpConnectionTest.cc \
|
TimeTest.cc CopyDiskAdaptorTest.cc FtpConnectionTest.cc \
|
||||||
OptionParserTest.cc SimpleDNSCacheTest.cc \
|
OptionParserTest.cc SimpleDNSCacheTest.cc \
|
||||||
DownloadHelperTest.cc BencodeTest.cc $(am__append_1) \
|
DownloadHelperTest.cc BencodeTest.cc SequentialPickerTest.cc \
|
||||||
$(am__append_2) $(am__append_3) $(am__append_4) \
|
$(am__append_1) $(am__append_2) $(am__append_3) \
|
||||||
$(am__append_5)
|
$(am__append_4) $(am__append_5)
|
||||||
|
|
||||||
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
||||||
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
||||||
|
@ -796,6 +798,7 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentManTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentManTest.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentTest.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SequenceTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SequenceTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SequentialPickerTest.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatManTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatManTest.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatTest.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatURISelectorTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatURISelectorTest.Po@am__quote@
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
#include "SequentialPicker.h"
|
||||||
|
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
namespace aria2 {
|
||||||
|
|
||||||
|
typedef SharedHandle<int> Integer;
|
||||||
|
|
||||||
|
class SequentialPickerTest:public CppUnit::TestFixture {
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(SequentialPickerTest);
|
||||||
|
CPPUNIT_TEST(testPick);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
public:
|
||||||
|
void testPick();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION(SequentialPickerTest);
|
||||||
|
|
||||||
|
void SequentialPickerTest::testPick()
|
||||||
|
{
|
||||||
|
SequentialPicker<int> picker;
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(!picker.isPicked());
|
||||||
|
CPPUNIT_ASSERT(!picker.hasNext());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)0, picker.countEntryInQueue());
|
||||||
|
|
||||||
|
picker.pushEntry(Integer(new int(1)));
|
||||||
|
picker.pushEntry(Integer(new int(2)));
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(picker.hasNext());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)2, picker.countEntryInQueue());
|
||||||
|
|
||||||
|
picker.pickNext();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(picker.isPicked());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(Integer(new int(1)), picker.getPickedEntry());
|
||||||
|
|
||||||
|
picker.dropPickedEntry();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(!picker.isPicked());
|
||||||
|
CPPUNIT_ASSERT(picker.hasNext());
|
||||||
|
|
||||||
|
picker.pickNext();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(Integer(new int(2)), picker.getPickedEntry());
|
||||||
|
CPPUNIT_ASSERT(!picker.hasNext());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace aria2
|
Loading…
Reference in New Issue