forked from yedf2/handy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.cc
More file actions
25 lines (24 loc) · 679 Bytes
/
Copy pathtimer.cc
File metadata and controls
25 lines (24 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <handy/handy.h>
using namespace handy;
int main(int argc, const char* argv[]) {
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
info("program begin");
base.runAfter(200, [](){
info("a task in runAfter 200ms");
});
base.runAfter(100, [](){
info("a task in runAfter 100ms interval 1000ms");
}, 1000);
TimerId id = base.runAt(time(NULL)*1000+300, [](){
info("a task in runAt now+300 interval 500ms");
}, 500);
base.runAfter(2000, [&](){
info("cancel task of interval 500ms");
base.cancel(id);
});
base.runAfter(3000, [&](){
base.exit();
});
base.loop();
}