/* */ #include "SleepCommand.h" #include "RequestGroup.h" #include "DownloadEngine.h" #include "DownloadContext.h" #include "wallclock.h" #include "RequestGroupMan.h" #include "FileAllocationEntry.h" #include "CheckIntegrityEntry.h" #include "ServerStatMan.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->addCommand(_nextCommand); _nextCommand = 0; return true; } else { _engine->addCommand(this); return false; } } } // namespace aria2