/* */ #include "TimeBasedCommand.h" #include "DownloadEngine.h" #include "wallclock.h" namespace aria2 { TimeBasedCommand::TimeBasedCommand(cuid_t cuid, DownloadEngine* e, time_t interval, bool routineCommand): Command(cuid), e_(e),exit_(false), interval_(interval), routineCommand_(routineCommand), checkPoint_(global::wallclock) {} TimeBasedCommand::~TimeBasedCommand() {} bool TimeBasedCommand::execute() { preProcess(); if(exit_) { return true; } if(checkPoint_.difference(global::wallclock) >= interval_) { checkPoint_ = global::wallclock; process(); if(exit_) { return true; } } postProcess(); if(exit_) { return true; } if(routineCommand_) { e_->addRoutineCommand(this); } else { e_->addCommand(this); } return false; } } // namespace aria2