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