-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (25 loc) · 713 Bytes
/
main.cpp
File metadata and controls
35 lines (25 loc) · 713 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
#include <iostream>
#include "Looper.h"
#include "Runnable.h"
#include <functional>
#include <chrono>
#include <thread>
#include <string>
void print(void* arg){
std::cout<< *reinterpret_cast<std::string*>(arg) <<std::endl;
delete reinterpret_cast<std::string*>(arg);
std::cout<<"runnable" <<std::endl;
}
int main() {
mtl::Looper looper;
std::function<void(void *)> fun = print;
for (int i = 0; i < 100; ++i) {
auto str = new std::string;
*str = std::to_string(i);
auto runnable = new mtl::Runnable(fun, str, true);
looper.add(runnable);
}
looper.run();
std::this_thread::sleep_for(std::chrono::seconds(5));
looper.stopAndJoin();
}