/* */ #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