-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogicActor.cpp
More file actions
79 lines (67 loc) · 2.04 KB
/
Copy pathLogicActor.cpp
File metadata and controls
79 lines (67 loc) · 2.04 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "LogicActor.h"
LogicActor::LogicActor()
{
thread_ = ActiveThread::Create(std::bind(&LogicActor::Handler, this, std::placeholders::_1));
}
LogicActor::~LogicActor()
{
delete thread_;
}
void LogicActor::Handler(buffer_base*& pBuffer)
{
if (!pBuffer)
{
std::cout << "LogicActor::handler" << std::endl;
return;
}
switch (pBuffer->GetType()) {
case 0:
break;
default:
break;
}
}
void LogicActor::Start() {
thread_->AddTimer(std::bind(&LogicActor::hb_sys,this, std::placeholders::_1, std::placeholders::_2),2000,eTType_sys,true);
thread_->AddTimer(std::bind(&LogicActor::hb_hr, this, std::placeholders::_1, std::placeholders::_2), 2000, eTType_hr, true);
thread_->AddTimer(std::bind(&LogicActor::hb_sdy, this, std::placeholders::_1, std::placeholders::_2), 2000, eTType_sdy, true);
thread_->AddTimer(std::bind(&LogicActor::hb_dl, this, std::placeholders::_1, std::placeholders::_2), 3000, eTType_dline, true);
thread_->Start();
}
void LogicActor::Send2LogicThread(const char* pData, int n32Length) {
thread_->Send(pData, n32Length);
}
void LogicActor::Send2LogicThread(buffer_base* pBuffer) {
thread_->Send(pBuffer);
}
int sys_call_time = 3;
void LogicActor::hb_sys(__int64 curTime, __int64 spanTime)
{
if (sys_call_time > 0)
{
std::cout << "sys:" << curTime << "-" << spanTime << "\n";
sys_call_time--;
}
}
int hr_call_time = 3;
void LogicActor::hb_hr(__int64 curTime, __int64 spanTime) {
if (hr_call_time > 0)
{
std::cout << "hr:" << curTime << "-" << spanTime << "\n";
hr_call_time--;
}
}
int sdy_call_time = 3;
void LogicActor::hb_sdy(__int64 curTime, __int64 spanTime) {
if (sdy_call_time > 0) {
sdy_call_time--;
std::cout << "sdy:" << curTime << "-" << spanTime << "\n";
}
}
int dl_call_time = 2;
void LogicActor::hb_dl(__int64 curTime, __int64 spanTime) {
if (dl_call_time > 0) {
dl_call_time--;
std::cout << "dl:" << curTime << "-" << spanTime << "\n";
}
}