Fix regression: switch back to microseconds for DelayCmd

This commit is contained in:
Mathias Gumz 2012-09-14 08:51:42 +02:00
parent 59d097bcea
commit 2f279e96b1
2 changed files with 12 additions and 8 deletions

View file

@ -239,21 +239,21 @@ Command<void> *DelayedCmd::parse(const std::string &command,
if (cmd == 0) if (cmd == 0)
return 0; return 0;
int delay = 200; uint64_t delay = 200;
StringUtil::fromString<int>(args.c_str() + err, delay); StringUtil::fromString<uint64_t>(args.c_str() + err, delay);
return new DelayedCmd(cmd, delay); return new DelayedCmd(cmd, delay);
} }
REGISTER_COMMAND_PARSER(delay, DelayedCmd::parse, void); REGISTER_COMMAND_PARSER(delay, DelayedCmd::parse, void);
DelayedCmd::DelayedCmd(const RefCount<Slot<void> > &cmd, unsigned int timeout) { DelayedCmd::DelayedCmd(const RefCount<Slot<void> > &cmd, uint64_t timeout) {
initTimer(timeout); initTimer(timeout);
m_timer.setCommand(cmd); m_timer.setCommand(cmd);
} }
void DelayedCmd::initTimer(unsigned int timeout) { void DelayedCmd::initTimer(uint64_t timeout) {
m_timer.setTimeout(timeout * FbTime::IN_MILLISECONDS); m_timer.setTimeout(timeout);
m_timer.fireOnce(true); m_timer.fireOnce(true);
} }

View file

@ -85,15 +85,19 @@ private:
uint64_t m_timeout; ///< time length in microseconds uint64_t m_timeout; ///< time length in microseconds
}; };
/// executes a command after a specified timeout /// executes a command after a specified timeout
class DelayedCmd: public Command<void> { class DelayedCmd: public Command<void> {
public: public:
DelayedCmd(const RefCount<Slot<void> > &cmd, unsigned int timeout = 200);
// timeout in microseconds
DelayedCmd(const RefCount<Slot<void> > &cmd, uint64_t timeout = 200);
// this constructor has inverted order of parameters to avoid ambiguity with the previous // this constructor has inverted order of parameters to avoid ambiguity with the previous
// constructor // constructor
template<typename Functor> template<typename Functor>
DelayedCmd(unsigned int timeout, const Functor &functor) { DelayedCmd(uint64_t timeout, const Functor &functor) {
initTimer(timeout); initTimer(timeout);
m_timer.setFunctor(functor); m_timer.setFunctor(functor);
} }
@ -102,7 +106,7 @@ public:
static Command<void> *parse(const std::string &command, static Command<void> *parse(const std::string &command,
const std::string &args, bool trusted); const std::string &args, bool trusted);
private: private:
void initTimer(unsigned int timeout); void initTimer(uint64_t timeout);
Timer m_timer; Timer m_timer;
}; };