/* */ #include "SleepCommand.h" #include "RequestGroup.h" #include "DownloadEngine.h" namespace aria2 { SleepCommand::SleepCommand(int32_t cuid, DownloadEngine* e, RequestGroup* requestGroup, Command* nextCommand, time_t wait): Command(cuid), engine(e), _requestGroup(requestGroup), nextCommand(nextCommand), wait(wait) {} SleepCommand::~SleepCommand() { if(nextCommand) { delete(nextCommand); } } bool SleepCommand::execute() { if(_requestGroup->downloadFinished() || _requestGroup->isHaltRequested()) { return true; } else if(checkPoint.elapsed(wait)) { engine->commands.push_back(nextCommand); nextCommand = 0; return true; } else { engine->commands.push_back(this); return false; } } } // namespace aria2