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