-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathhandler_tutorial.cc
More file actions
37 lines (28 loc) · 933 Bytes
/
handler_tutorial.cc
File metadata and controls
37 lines (28 loc) · 933 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
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <memory>
#include "handler.h"
using namespace std;
using namespace es;
int main(int argc, char **argv) {
cout << "Handler tutorial" << endl;
Handler hdlr;
hdlr.handleMessage([](const Message &msg) {
switch (msg.what) {
case 0: break;
case 1: break;
default: break;
}
cout << "Handler what: " << msg.what << endl;
});
for (int i = 0; i < 6; i++) {
hdlr.sendEmptyMessageDelay(i + 1, 1000 * i);
}
hdlr.postDelay([]() { cout << "POST call back" << endl; }, 230);
std::this_thread::sleep_until(std::chrono::steady_clock::now() + std::chrono::seconds(3));
hdlr.removeMessages(6);
std::this_thread::sleep_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
hdlr.removeAlls();
// hdlr.stop();
cout << "Program exit !" << endl;
return 1;
}