/* */ #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::difftvsec(now, checkPoint) >= wait) { engine->commands.push_back(nextCommand); nextCommand = NULL; return true; } else { engine->commands.push_back(this); return false; } }