/* */ #include "SleepCommand.h" #include "Util.h" SleepCommand::SleepCommand(int cuid, DownloadEngine* e, Command* nextCommand, int wait): Command(cuid), engine(e), nextCommand(nextCommand), wait(wait) { gettimeofday(&checkPoint, NULL); } SleepCommand::~SleepCommand() { if(nextCommand != NULL) { delete(nextCommand); } } bool SleepCommand::execute() { struct timeval now; gettimeofday(&now, NULL); if(Util::difftv(now, checkPoint) >= ((long long int)wait)*1000000) { engine->commands.push(nextCommand); nextCommand = NULL; return true; } else { engine->commands.push(this); return false; } }