FbTk::Timer accepts Slots instead of Commands as the former are more general
This commit is contained in:
parent
d338e6c003
commit
cfcc4d44aa
2 changed files with 8 additions and 8 deletions
|
@ -59,7 +59,7 @@ Timer::Timer():m_timing(false), m_once(false), m_interval(0) {
|
|||
|
||||
}
|
||||
|
||||
Timer::Timer(RefCount<Command<void> > &handler):
|
||||
Timer::Timer(const RefCount<Slot<void> > &handler):
|
||||
m_handler(handler),
|
||||
m_timing(false),
|
||||
m_once(false),
|
||||
|
@ -90,7 +90,7 @@ void Timer::setTimeout(unsigned int secs, unsigned int usecs) {
|
|||
m_timeout.tv_usec = usecs;
|
||||
}
|
||||
|
||||
void Timer::setCommand(RefCount<Command<void> > &cmd) {
|
||||
void Timer::setCommand(const RefCount<Slot<void> > &cmd) {
|
||||
m_handler = cmd;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ void Timer::makeEndTime(timeval &tm) const {
|
|||
|
||||
void Timer::fireTimeout() {
|
||||
if (m_handler)
|
||||
m_handler->execute();
|
||||
(*m_handler)();
|
||||
}
|
||||
|
||||
void Timer::updateTimers(int fd) {
|
||||
|
@ -284,7 +284,7 @@ Command<void> *DelayedCmd::parse(const std::string &command,
|
|||
|
||||
REGISTER_COMMAND_PARSER(delay, DelayedCmd::parse, void);
|
||||
|
||||
DelayedCmd::DelayedCmd(RefCount<Command<void> > &cmd, unsigned int timeout) {
|
||||
DelayedCmd::DelayedCmd(const RefCount<Slot<void> > &cmd, unsigned int timeout) {
|
||||
timeval to; // defaults to 200ms
|
||||
to.tv_sec = timeout/1000000;
|
||||
to.tv_usec = timeout % 1000000;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace FbTk {
|
|||
class Timer {
|
||||
public:
|
||||
Timer();
|
||||
explicit Timer(RefCount<Command<void> > &handler);
|
||||
explicit Timer(const RefCount<Slot<void> > &handler);
|
||||
virtual ~Timer();
|
||||
|
||||
void fireOnce(bool once) { m_once = once; }
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
/// set timeout
|
||||
void setTimeout(const timeval &val);
|
||||
void setTimeout(unsigned int secs, unsigned int usecs);
|
||||
void setCommand(RefCount<Command<void> > &cmd);
|
||||
void setCommand(const RefCount<Slot<void> > &cmd);
|
||||
void setInterval(int val) { m_interval = val; }
|
||||
/// start timing
|
||||
void start();
|
||||
|
@ -96,7 +96,7 @@ private:
|
|||
typedef std::list<Timer *> TimerList;
|
||||
static TimerList m_timerlist; ///< list of all timers, sorted by next trigger time (start + timeout)
|
||||
|
||||
RefCount<Command<void> > m_handler; ///< what to do on a timeout
|
||||
RefCount<Slot<void> > m_handler; ///< what to do on a timeout
|
||||
|
||||
bool m_timing; ///< clock running?
|
||||
bool m_once; ///< do timeout only once?
|
||||
|
@ -110,7 +110,7 @@ private:
|
|||
/// executes a command after a specified timeout
|
||||
class DelayedCmd: public Command<void> {
|
||||
public:
|
||||
DelayedCmd(RefCount<Command<void> > &cmd, unsigned int timeout = 200000);
|
||||
DelayedCmd(const RefCount<Slot<void> > &cmd, unsigned int timeout = 200000);
|
||||
void execute();
|
||||
static Command<void> *parse(const std::string &command,
|
||||
const std::string &args, bool trusted);
|
||||
|
|
Loading…
Reference in a new issue