From a20aa3c7e544c0fc32fb1d8a5f04b24cfd026267 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 24 Jan 2009 09:49:37 +0000 Subject: 2009-01-24 Tatsuhiro Tsujikawa Rewritten FileAllocationDispatcherCommand using brand new SequentialDispatcherCommand. * src/DownloadEngineFactory.cc * src/FileAllocationCommand.cc * src/FileAllocationDispatcherCommand.cc * src/FileAllocationDispatcherCommand.h * src/Makefile.am * src/SequentialDispatcherCommand.h --- src/FileAllocationDispatcherCommand.cc | 39 +++++++++++----------------------- 1 file changed, 12 insertions(+), 27 deletions(-) (limited to 'src/FileAllocationDispatcherCommand.cc') diff --git a/src/FileAllocationDispatcherCommand.cc b/src/FileAllocationDispatcherCommand.cc index b6ee18fa..5e5e996c 100644 --- a/src/FileAllocationDispatcherCommand.cc +++ b/src/FileAllocationDispatcherCommand.cc @@ -33,9 +33,6 @@ */ /* copyright --> */ #include "FileAllocationDispatcherCommand.h" -#include "DownloadEngine.h" -#include "RequestGroupMan.h" -#include "FileAllocationMan.h" #include "FileAllocationEntry.h" #include "FileAllocationCommand.h" #include "message.h" @@ -43,35 +40,23 @@ namespace aria2 { -FileAllocationDispatcherCommand::FileAllocationDispatcherCommand(int32_t cuid, DownloadEngine* e): - Command(cuid), _e(e) +FileAllocationDispatcherCommand::FileAllocationDispatcherCommand +(int32_t cuid, + const SharedHandle& fileAllocMan, + DownloadEngine* e):SequentialDispatcherCommand + (cuid, fileAllocMan, e) { setStatusRealtime(); } -FileAllocationDispatcherCommand::~FileAllocationDispatcherCommand() {} - -bool FileAllocationDispatcherCommand::execute() +Command* FileAllocationDispatcherCommand::createCommand +(const SharedHandle& entry) { - if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) { - return true; - } - if(_e->_fileAllocationMan->hasNext() && !_e->_fileAllocationMan->isPicked()) { - FileAllocationEntryHandle entry = _e->_fileAllocationMan->pickNext(); - int32_t newCUID = _e->newCUID(); - logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID); - FileAllocationCommand* command = - new FileAllocationCommand(newCUID, - entry->getRequestGroup(), - _e, - entry); - _e->commands.push_back(command); - _e->setNoWait(true); - } - - _e->addRoutineCommand(this); - - return false; + int32_t newCUID = _e->newCUID(); + logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID); + FileAllocationCommand* command = + new FileAllocationCommand(newCUID, entry->getRequestGroup(), _e, entry); + return command; } } // namespace aria2 -- cgit