-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingTimer.cpp
More file actions
47 lines (35 loc) · 884 Bytes
/
SettingTimer.cpp
File metadata and controls
47 lines (35 loc) · 884 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
38
39
40
41
42
43
44
45
46
// SettingTimer.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "Timer.h"
#include <iostream>
#include<string>
#include <memory.h>
using namespace std;
void EhcoFunc(std::string &s)
{
cout << "test:" << s << endl;
}
int main()
{
Timer T;
#if 0
// 周期性执行问题
T.StartTimer(1000, std::bind(EhcoFunc, "Hello World!"));
std::this_thread::sleep_for(std::chrono::seconds(4));
std::cout << "try_to_expired_timer" << endl;
T.Expire();
//周期性执行定时任务
T.StartTimer(1000, std::bind(EhcoFunc, "hello c++11!"));
std::this_thread::sleep_for(std::chrono::seconds(4));
std::cout << "try to expire timer!" << std::endl;
T.Expire();
//
std::this_thread::sleep_for(std::chrono::seconds(2));
#endif
//
T.SyncWait(100, EhcoFunc, "Hello");
T.AsyncWait(1000, EhcoFunc, "World");
std::this_thread::sleep_for(std::chrono::seconds(2));
return 0;
}