/* */ #include "SleepCommand.h" #include "RequestGroup.h" #include "DownloadEngine.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_.differenceInMillis(global::wallclock())+A2_DELTA_MILLIS >= wait_*1000) { engine_->addCommand(nextCommand_); nextCommand_ = 0; engine_->setNoWait(true); return true; } else { engine_->addCommand(this); return false; } } } // namespace aria2