mirror of https://github.com/aria2/aria2
2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Eliminates the time lag between sequential downloads and commands in the same RequestGroup. In old implementation, aria2 occasionally waits 1 seconds before executing next command or RequestGroup. This is really a waste of time, and new implementation eliminates this unnecessary time lag. * src/AbstractCommand.cc * src/AutoSaveCommand.cc * src/CheckIntegrityCommand.cc * src/Command.{cc, h} * src/DownloadEngine.{cc, h} * src/DownloadEngineFactory.cc * src/FileAllocationCommand.cc * src/FileAllocationDispatcherCommand.cc * src/FillRequestGroupCommand.cc * src/FtpInitiateConnectionCommand.cc * src/HaveEraseCommand.cc * src/HttpInitiateConnectionCommand.cc * src/HttpResponseCommand.cc * src/RealtimeCommand.cc * src/RequestGroup.cc * src/RequestGroupMan.cc * src/StreamFileAllocationEntry.cc * src/TimeBasedCommand.{cc, h} * src/TimedHaltCommand.ccpull/1/head
parent
3505201f33
commit
c1c5e7369f
28
ChangeLog
28
ChangeLog
|
@ -1,3 +1,31 @@
|
||||||
|
2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Eliminates the time lag between sequential downloads and commands in
|
||||||
|
the same RequestGroup.
|
||||||
|
In old implementation, aria2 occasionally waits 1 seconds before
|
||||||
|
executing next command or RequestGroup.
|
||||||
|
This is really a waste of time, and new implementation eliminates
|
||||||
|
this unnecessary time lag.
|
||||||
|
* src/AbstractCommand.cc
|
||||||
|
* src/AutoSaveCommand.cc
|
||||||
|
* src/CheckIntegrityCommand.cc
|
||||||
|
* src/Command.{cc, h}
|
||||||
|
* src/DownloadEngine.{cc, h}
|
||||||
|
* src/DownloadEngineFactory.cc
|
||||||
|
* src/FileAllocationCommand.cc
|
||||||
|
* src/FileAllocationDispatcherCommand.cc
|
||||||
|
* src/FillRequestGroupCommand.cc
|
||||||
|
* src/FtpInitiateConnectionCommand.cc
|
||||||
|
* src/HaveEraseCommand.cc
|
||||||
|
* src/HttpInitiateConnectionCommand.cc
|
||||||
|
* src/HttpResponseCommand.cc
|
||||||
|
* src/RealtimeCommand.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* src/RequestGroupMan.cc
|
||||||
|
* src/StreamFileAllocationEntry.cc
|
||||||
|
* src/TimeBasedCommand.{cc, h}
|
||||||
|
* src/TimedHaltCommand.cc
|
||||||
|
|
||||||
2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Rewritten SharedHandle. Now copy constructor taking raw pointer has
|
Rewritten SharedHandle. Now copy constructor taking raw pointer has
|
||||||
|
|
|
@ -190,6 +190,7 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
|
||||||
}
|
}
|
||||||
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, req, _requestGroup, e);
|
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, req, _requestGroup, e);
|
||||||
if(wait == 0) {
|
if(wait == 0) {
|
||||||
|
e->setNoWait(true);
|
||||||
e->commands.push_back(command);
|
e->commands.push_back(command);
|
||||||
} else {
|
} else {
|
||||||
SleepCommand* scom = new SleepCommand(cuid, e, command, wait);
|
SleepCommand* scom = new SleepCommand(cuid, e, command, wait);
|
||||||
|
@ -318,6 +319,7 @@ void AbstractCommand::prepareForNextAction(Command* nextCommand)
|
||||||
{
|
{
|
||||||
CheckIntegrityEntryHandle entry(new StreamCheckIntegrityEntry(req, _requestGroup, nextCommand));
|
CheckIntegrityEntryHandle entry(new StreamCheckIntegrityEntry(req, _requestGroup, nextCommand));
|
||||||
e->addCommand(_requestGroup->processCheckIntegrityEntry(entry, e));
|
e->addCommand(_requestGroup->processCheckIntegrityEntry(entry, e));
|
||||||
|
e->setNoWait(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
AutoSaveCommand::AutoSaveCommand(int32_t cuid, DownloadEngine* e, time_t interval):
|
AutoSaveCommand::AutoSaveCommand(int32_t cuid, DownloadEngine* e, time_t interval):
|
||||||
TimeBasedCommand(cuid, e, interval) {}
|
TimeBasedCommand(cuid, e, interval, true) {}
|
||||||
|
|
||||||
AutoSaveCommand::~AutoSaveCommand() {}
|
AutoSaveCommand::~AutoSaveCommand() {}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ bool CheckIntegrityCommand::executeInternal()
|
||||||
_requestGroup->getFilePath().c_str());
|
_requestGroup->getFilePath().c_str());
|
||||||
_e->addCommand(_entry->onDownloadIncomplete(_e));
|
_e->addCommand(_entry->onDownloadIncomplete(_e));
|
||||||
}
|
}
|
||||||
|
_e->setNoWait(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->commands.push_back(this);
|
||||||
|
|
|
@ -55,4 +55,9 @@ void Command::transitStatus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Command::setStatus(STATUS status)
|
||||||
|
{
|
||||||
|
this->status = status;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -51,7 +51,8 @@ public:
|
||||||
STATUS_ALL,
|
STATUS_ALL,
|
||||||
STATUS_INACTIVE,
|
STATUS_INACTIVE,
|
||||||
STATUS_ACTIVE,
|
STATUS_ACTIVE,
|
||||||
STATUS_REALTIME
|
STATUS_REALTIME,
|
||||||
|
STATUS_ONESHOT_REALTIME
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
CommandUuid uuid;
|
CommandUuid uuid;
|
||||||
|
@ -77,6 +78,8 @@ public:
|
||||||
|
|
||||||
void setStatusRealtime() { this->status = STATUS_REALTIME; }
|
void setStatusRealtime() { this->status = STATUS_REALTIME; }
|
||||||
|
|
||||||
|
void setStatus(STATUS status);
|
||||||
|
|
||||||
bool statusMatch(Command::STATUS statusFilter) const
|
bool statusMatch(Command::STATUS statusFilter) const
|
||||||
{
|
{
|
||||||
return statusFilter <= status;
|
return statusFilter <= status;
|
||||||
|
|
|
@ -85,7 +85,7 @@ bool NameResolverEntry::operator==(const NameResolverEntry& entry)
|
||||||
|
|
||||||
DownloadEngine::DownloadEngine():logger(LogFactory::getInstance()),
|
DownloadEngine::DownloadEngine():logger(LogFactory::getInstance()),
|
||||||
_haltRequested(false),
|
_haltRequested(false),
|
||||||
noWait(false)
|
_noWait(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DownloadEngine::~DownloadEngine() {
|
DownloadEngine::~DownloadEngine() {
|
||||||
|
@ -105,7 +105,8 @@ void DownloadEngine::cleanQueue() {
|
||||||
commands.clear();
|
commands.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadEngine::executeCommand(Command::STATUS statusFilter)
|
static void executeCommand(std::deque<Command*>& commands,
|
||||||
|
Command::STATUS statusFilter)
|
||||||
{
|
{
|
||||||
size_t max = commands.size();
|
size_t max = commands.size();
|
||||||
for(size_t i = 0; i < max; i++) {
|
for(size_t i = 0; i < max; i++) {
|
||||||
|
@ -126,19 +127,19 @@ void DownloadEngine::executeCommand(Command::STATUS statusFilter)
|
||||||
void DownloadEngine::run() {
|
void DownloadEngine::run() {
|
||||||
Time cp;
|
Time cp;
|
||||||
cp.setTimeInSec(0);
|
cp.setTimeInSec(0);
|
||||||
Commands activeCommands;
|
|
||||||
while(!commands.empty()) {
|
while(!commands.empty()) {
|
||||||
if(cp.elapsed(1)) {
|
if(cp.elapsed(1)) {
|
||||||
cp.reset();
|
cp.reset();
|
||||||
executeCommand(Command::STATUS_ALL);
|
executeCommand(commands, Command::STATUS_ALL);
|
||||||
} else {
|
} else {
|
||||||
executeCommand(Command::STATUS_ACTIVE);
|
executeCommand(commands, Command::STATUS_ACTIVE);
|
||||||
}
|
}
|
||||||
|
executeCommand(_routineCommands, Command::STATUS_ALL);
|
||||||
afterEachIteration();
|
afterEachIteration();
|
||||||
if(!commands.empty()) {
|
if(!commands.empty()) {
|
||||||
waitData();
|
waitData();
|
||||||
}
|
}
|
||||||
noWait = false;
|
_noWait = false;
|
||||||
calculateStatistics();
|
calculateStatistics();
|
||||||
}
|
}
|
||||||
onEndOfRun();
|
onEndOfRun();
|
||||||
|
@ -173,7 +174,7 @@ void DownloadEngine::waitData() {
|
||||||
}
|
}
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
|
|
||||||
tv.tv_sec = noWait ? 0 : 1;
|
tv.tv_sec = _noWait ? 0 : 1;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
int retval = select(fdmax+1, &rfds, &wfds, NULL, &tv);
|
int retval = select(fdmax+1, &rfds, &wfds, NULL, &tv);
|
||||||
if(retval > 0) {
|
if(retval > 0) {
|
||||||
|
@ -350,4 +351,14 @@ bool DownloadEngine::deleteNameResolverCheck(const NameResolverHandle& resolver,
|
||||||
}
|
}
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
|
|
||||||
|
void DownloadEngine::setNoWait(bool b)
|
||||||
|
{
|
||||||
|
_noWait = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadEngine::addRoutineCommand(Command* command)
|
||||||
|
{
|
||||||
|
_routineCommands.push_back(command);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -107,7 +107,6 @@ private:
|
||||||
void shortSleep() const;
|
void shortSleep() const;
|
||||||
bool addSocket(const SocketEntry& socketEntry);
|
bool addSocket(const SocketEntry& socketEntry);
|
||||||
bool deleteSocket(const SocketEntry& socketEntry);
|
bool deleteSocket(const SocketEntry& socketEntry);
|
||||||
void executeCommand(Command::STATUS statusFilter);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delegates to StatCalc
|
* Delegates to StatCalc
|
||||||
|
@ -118,8 +117,12 @@ private:
|
||||||
|
|
||||||
void afterEachIteration();
|
void afterEachIteration();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _noWait;
|
||||||
|
|
||||||
|
std::deque<Command*> _routineCommands;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool noWait;
|
|
||||||
std::deque<Command*> commands;
|
std::deque<Command*> commands;
|
||||||
SharedHandle<RequestGroupMan> _requestGroupMan;
|
SharedHandle<RequestGroupMan> _requestGroupMan;
|
||||||
SharedHandle<FileAllocationMan> _fileAllocationMan;
|
SharedHandle<FileAllocationMan> _fileAllocationMan;
|
||||||
|
@ -163,6 +166,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestHalt();
|
void requestHalt();
|
||||||
|
|
||||||
|
void setNoWait(bool b);
|
||||||
|
|
||||||
|
void addRoutineCommand(Command* command);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<DownloadEngine> DownloadEngineHandle;
|
typedef SharedHandle<DownloadEngine> DownloadEngineHandle;
|
||||||
|
|
|
@ -83,14 +83,14 @@ DownloadEngineFactory::newDownloadEngine(Option* op,
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->_checkIntegrityMan.reset(new CheckIntegrityMan());
|
e->_checkIntegrityMan.reset(new CheckIntegrityMan());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
e->commands.push_back(new FillRequestGroupCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 1));
|
e->addRoutineCommand(new FillRequestGroupCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 1));
|
||||||
e->commands.push_back(new FileAllocationDispatcherCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get()));
|
e->addRoutineCommand(new FileAllocationDispatcherCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get()));
|
||||||
e->commands.push_back(new AutoSaveCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), op->getAsInt(PREF_AUTO_SAVE_INTERVAL)));
|
e->addRoutineCommand(new AutoSaveCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), op->getAsInt(PREF_AUTO_SAVE_INTERVAL)));
|
||||||
e->commands.push_back(new HaveEraseCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 10));
|
e->addRoutineCommand(new HaveEraseCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 10));
|
||||||
{
|
{
|
||||||
time_t stopSec = op->getAsInt(PREF_STOP);
|
time_t stopSec = op->getAsInt(PREF_STOP);
|
||||||
if(stopSec > 0) {
|
if(stopSec > 0) {
|
||||||
e->commands.push_back(new TimedHaltCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), stopSec));
|
e->addRoutineCommand(new TimedHaltCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), stopSec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
|
|
|
@ -63,7 +63,7 @@ bool FileAllocationCommand::executeInternal()
|
||||||
_e->_fileAllocationMan->markCurrentFileAllocationEntryDone();
|
_e->_fileAllocationMan->markCurrentFileAllocationEntryDone();
|
||||||
|
|
||||||
_e->addCommand(_fileAllocationEntry->prepareForNextAction(_e));
|
_e->addCommand(_fileAllocationEntry->prepareForNextAction(_e));
|
||||||
|
_e->setNoWait(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->commands.push_back(this);
|
||||||
|
|
|
@ -68,10 +68,10 @@ bool FileAllocationDispatcherCommand::execute()
|
||||||
_e,
|
_e,
|
||||||
entry);
|
entry);
|
||||||
_e->commands.push_back(command);
|
_e->commands.push_back(command);
|
||||||
_e->noWait = true;
|
_e->setNoWait(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_e->commands.push_back(this);
|
_e->addRoutineCommand(this);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool FillRequestGroupCommand::execute()
|
||||||
if(_e->_requestGroupMan->downloadFinished()) {
|
if(_e->_requestGroupMan->downloadFinished()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_e->commands.push_back(this);
|
_e->addRoutineCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ FtpInitiateConnectionCommand::FtpInitiateConnectionCommand(int cuid,
|
||||||
nameResolver(new NameResolver())
|
nameResolver(new NameResolver())
|
||||||
{
|
{
|
||||||
setTimeout(e->option->getAsInt(PREF_DNS_TIMEOUT));
|
setTimeout(e->option->getAsInt(PREF_DNS_TIMEOUT));
|
||||||
setStatusActive();
|
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
disableReadCheckSocket();
|
disableReadCheckSocket();
|
||||||
disableWriteCheckSocket();
|
disableWriteCheckSocket();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
HaveEraseCommand::HaveEraseCommand(int32_t cuid, DownloadEngine* e, time_t interval)
|
HaveEraseCommand::HaveEraseCommand(int32_t cuid, DownloadEngine* e, time_t interval)
|
||||||
:TimeBasedCommand(cuid, e, interval) {}
|
:TimeBasedCommand(cuid, e, interval, true) {}
|
||||||
|
|
||||||
HaveEraseCommand::~HaveEraseCommand() {}
|
HaveEraseCommand::~HaveEraseCommand() {}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ HttpInitiateConnectionCommand::HttpInitiateConnectionCommand(int cuid,
|
||||||
nameResolver(new NameResolver())
|
nameResolver(new NameResolver())
|
||||||
{
|
{
|
||||||
setTimeout(e->option->getAsInt(PREF_DNS_TIMEOUT));
|
setTimeout(e->option->getAsInt(PREF_DNS_TIMEOUT));
|
||||||
setStatusActive();
|
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
disableReadCheckSocket();
|
disableReadCheckSocket();
|
||||||
disableWriteCheckSocket();
|
disableWriteCheckSocket();
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,6 @@ bool HttpResponseCommand::executeInternal()
|
||||||
if(httpResponse->isRedirect()) {
|
if(httpResponse->isRedirect()) {
|
||||||
httpResponse->processRedirect();
|
httpResponse->processRedirect();
|
||||||
logger->info(MSG_REDIRECT, cuid, httpResponse->getRedirectURI().c_str());
|
logger->info(MSG_REDIRECT, cuid, httpResponse->getRedirectURI().c_str());
|
||||||
e->noWait = true;
|
|
||||||
return prepareForRetry(0);
|
return prepareForRetry(0);
|
||||||
}
|
}
|
||||||
if(!_requestGroup->isSingleHostMultiConnectionEnabled()) {
|
if(!_requestGroup->isSingleHostMultiConnectionEnabled()) {
|
||||||
|
@ -152,7 +151,6 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
|
||||||
_requestGroup->getSegmentMan()->cancelSegment(cuid);
|
_requestGroup->getSegmentMan()->cancelSegment(cuid);
|
||||||
}
|
}
|
||||||
prepareForNextAction(command);
|
prepareForNextAction(command);
|
||||||
e->noWait = true;
|
|
||||||
} catch(Exception* e) {
|
} catch(Exception* e) {
|
||||||
delete command;
|
delete command;
|
||||||
throw;
|
throw;
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace aria2 {
|
||||||
bool RealtimeCommand::execute()
|
bool RealtimeCommand::execute()
|
||||||
{
|
{
|
||||||
setStatusRealtime();
|
setStatusRealtime();
|
||||||
_e->noWait = true;
|
_e->setNoWait(true);
|
||||||
try {
|
try {
|
||||||
return executeInternal();
|
return executeInternal();
|
||||||
} catch(Exception* e) {
|
} catch(Exception* e) {
|
||||||
|
|
|
@ -460,6 +460,8 @@ Commands RequestGroup::createNextCommand(DownloadEngine* e, unsigned int numComm
|
||||||
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), req, this, e);
|
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), req, this, e);
|
||||||
ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
||||||
registerServerHost(sv);
|
registerServerHost(sv);
|
||||||
|
// give a chance to be executed in the next loop in DownloadEngine
|
||||||
|
command->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
commands.push_back(command);
|
commands.push_back(command);
|
||||||
} else {
|
} else {
|
||||||
pendingURIs.push_front(uri);
|
pendingURIs.push_front(uri);
|
||||||
|
|
|
@ -166,6 +166,7 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
||||||
}
|
}
|
||||||
std::copy(temp.begin(), temp.end(), std::front_inserter(_reservedGroups));
|
std::copy(temp.begin(), temp.end(), std::front_inserter(_reservedGroups));
|
||||||
if(count > 0) {
|
if(count > 0) {
|
||||||
|
e->setNoWait(true);
|
||||||
_logger->debug("%d RequestGroup(s) added.", count);
|
_logger->debug("%d RequestGroup(s) added.", count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ Commands StreamFileAllocationEntry::prepareForNextAction(DownloadEngine* e)
|
||||||
{
|
{
|
||||||
Commands commands;
|
Commands commands;
|
||||||
if(_nextCommand) {
|
if(_nextCommand) {
|
||||||
|
// give _nextCommand a chance to execute in the next execution loop.
|
||||||
|
_nextCommand->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
commands.push_back(popNextCommand());
|
commands.push_back(popNextCommand());
|
||||||
// try remaining uris
|
// try remaining uris
|
||||||
Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, -1);
|
Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, -1);
|
||||||
|
|
|
@ -37,8 +37,11 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
TimeBasedCommand::TimeBasedCommand(int32_t cuid, DownloadEngine* e, time_t interval):
|
TimeBasedCommand::TimeBasedCommand(int32_t cuid, DownloadEngine* e,
|
||||||
Command(cuid), _e(e),_exit(false), _interval(interval) {}
|
time_t interval,
|
||||||
|
bool routineCommand):
|
||||||
|
Command(cuid), _e(e),_exit(false), _interval(interval),
|
||||||
|
_routineCommand(routineCommand) {}
|
||||||
|
|
||||||
TimeBasedCommand::~TimeBasedCommand() {}
|
TimeBasedCommand::~TimeBasedCommand() {}
|
||||||
|
|
||||||
|
@ -59,7 +62,11 @@ bool TimeBasedCommand::execute()
|
||||||
if(_exit) {
|
if(_exit) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_e->commands.push_back(this);
|
if(_routineCommand) {
|
||||||
|
_e->addRoutineCommand(this);
|
||||||
|
} else {
|
||||||
|
_e->commands.push_back(this);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ protected:
|
||||||
bool _exit;
|
bool _exit;
|
||||||
|
|
||||||
time_t _interval; // unit: sec
|
time_t _interval; // unit: sec
|
||||||
|
|
||||||
|
bool _routineCommand;
|
||||||
private:
|
private:
|
||||||
Time _checkPoint;
|
Time _checkPoint;
|
||||||
public:
|
public:
|
||||||
|
@ -77,7 +79,8 @@ public:
|
||||||
virtual void postProcess() {};
|
virtual void postProcess() {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TimeBasedCommand(int32_t cuid, DownloadEngine* e, time_t interval);
|
TimeBasedCommand(int32_t cuid, DownloadEngine* e, time_t interval,
|
||||||
|
bool routineCommand = false);
|
||||||
|
|
||||||
virtual ~TimeBasedCommand();
|
virtual ~TimeBasedCommand();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace aria2 {
|
||||||
|
|
||||||
TimedHaltCommand::TimedHaltCommand(int32_t cuid, DownloadEngine* e,
|
TimedHaltCommand::TimedHaltCommand(int32_t cuid, DownloadEngine* e,
|
||||||
time_t secondsToHalt):
|
time_t secondsToHalt):
|
||||||
TimeBasedCommand(cuid, e, secondsToHalt) {}
|
TimeBasedCommand(cuid, e, secondsToHalt, true) {}
|
||||||
|
|
||||||
TimedHaltCommand::~TimedHaltCommand() {}
|
TimedHaltCommand::~TimedHaltCommand() {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue