An example of how to use the AsyncAtTimer class
#include <iostream>
using namespace std;
class MyClass : public sigc::trackable
{
public:
MyClass(void)
{
timer.setExpireOffset(100);
timer.expired.connect(mem_fun(*this, &MyClass::onTimerExpired));
timeoutNextMinute();
timer.start();
}
~MyClass(void)
{
}
private:
void timeoutNextMinute(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm *tm = localtime(&tv.tv_sec);
tm->tm_min += 1;
tm->tm_sec = 0;
cout << "Setting timer to expire at " << asctime(tm);
}
{
struct timeval now;
gettimeofday(&now, NULL);
struct tm *tm = localtime(&now.tv_sec);
cout << "Timer expired at (+" << now.tv_usec / 1000 << "msec) "
<< asctime(tm) << endl;
timeoutNextMinute();
}
};
int main(int argc, char **argv)
{
MyClass my_class;
}
A timer that times out at a specified absolute time.
The core class for writing asyncronous cpp applications.
A timer that times out at a specified absolute time.
bool setTimeout(time_t t)
Set the timeout time.
An application class for writing non GUI applications.
void exec(void)
Execute the application main loop.
Namespace for the asynchronous programming classes.