/* */ #include "FileAllocationDispatcherCommand.h" #include "DownloadEngine.h" #include "RequestGroupMan.h" #include "FileAllocationMan.h" #include "FileAllocationEntry.h" #include "FileAllocationCommand.h" #include "message.h" #include "CUIDCounter.h" #include "Logger.h" namespace aria2 { FileAllocationDispatcherCommand::FileAllocationDispatcherCommand(int32_t cuid, DownloadEngine* e): Command(cuid), _e(e) { setStatusRealtime(); } FileAllocationDispatcherCommand::~FileAllocationDispatcherCommand() {} bool FileAllocationDispatcherCommand::execute() { if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) { return true; } if(_e->_fileAllocationMan->nextFileAllocationEntryExists() && !_e->_fileAllocationMan->isFileAllocationBeingExecuted()) { FileAllocationEntryHandle entry = _e->_fileAllocationMan->popNextFileAllocationEntry(); int32_t newCUID = CUIDCounterSingletonHolder::instance()->newID(); 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; } } // namespace aria2