Skip to content

Commit dc7aefc

Browse files
committed
added:help module
modify:Use of separate statistical notation for queue
1 parent b1914ad commit dc7aefc

File tree

18 files changed

+696
-9
lines changed

18 files changed

+696
-9
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#include "pch.h"
2+
#include "APIHelp_Counter.h"
3+
/********************************************************************
4+
// Created: 2025/03/11 14:49:15
5+
// File Name: D:\XEngine_MQService\XEngine_Source\MQCore_HelpModule\APIHelp_Counter\APIHelp_Counter.cpp
6+
// File Path: D:\XEngine_MQService\XEngine_Source\MQCore_HelpModule\APIHelp_Counter
7+
// File Base: APIHelp_Counter
8+
// File Ext: cpp
9+
// Project: XEngine
10+
// Author: qyt
11+
// Purpose: 帮助模块计数器
12+
// History:
13+
*********************************************************************/
14+
CAPIHelp_Counter::CAPIHelp_Counter()
15+
{
16+
}
17+
CAPIHelp_Counter::~CAPIHelp_Counter()
18+
{
19+
20+
}
21+
//////////////////////////////////////////////////////////////////////////
22+
// 公有函数
23+
//////////////////////////////////////////////////////////////////////////
24+
/********************************************************************
25+
函数名称:MemoryCache_DBData_DataSerialSet
26+
函数功能:设置当前序列号
27+
参数.一:lpszQueueName
28+
In/Out:In
29+
类型:常量字符指针
30+
可空:N
31+
意思:输入要插入的队列名称
32+
参数.二:nSerial
33+
In/Out:In
34+
类型:整数型
35+
可空:N
36+
意思:输入设置的队列序列号
37+
返回值
38+
类型:逻辑型
39+
意思:是否成功
40+
备注:
41+
*********************************************************************/
42+
bool CAPIHelp_Counter::APIHelp_Counter_SerialSet(LPCXSTR lpszQueueName, __int64x nSerial)
43+
{
44+
APIHelp_IsErrorOccur = false;
45+
46+
if (NULL == lpszQueueName)
47+
{
48+
APIHelp_IsErrorOccur = true;
49+
APIHelp_dwErrorCode = ERROR_XENGINE_MQCORE_APIHELP_COUNTER_PARAMENT;
50+
return false;
51+
}
52+
st_Locker.lock();
53+
stl_MapSerial[lpszQueueName] = nSerial;
54+
st_Locker.unlock();
55+
return true;
56+
}
57+
/********************************************************************
58+
函数名称:APIHelp_Counter_SerialGet
59+
函数功能:获取当前序列号
60+
参数.一:lpszQueueName
61+
In/Out:In
62+
类型:常量字符指针
63+
可空:N
64+
意思:输入要操作的队列名称
65+
参数.二:pInt_Serial
66+
In/Out:Out
67+
类型:整数型指针
68+
可空:N
69+
意思:输出当前队列序列号
70+
返回值
71+
类型:逻辑型
72+
意思:是否成功
73+
备注:
74+
*********************************************************************/
75+
bool CAPIHelp_Counter::APIHelp_Counter_SerialGet(LPCXSTR lpszQueueName, __int64x *pInt_Serial)
76+
{
77+
APIHelp_IsErrorOccur = false;
78+
79+
if (NULL == pInt_Serial)
80+
{
81+
APIHelp_IsErrorOccur = true;
82+
APIHelp_dwErrorCode = ERROR_XENGINE_MQCORE_APIHELP_COUNTER_PARAMENT;
83+
return false;
84+
}
85+
st_Locker.lock_shared();
86+
auto stl_MapIterator = stl_MapSerial.find(lpszQueueName);
87+
if (stl_MapIterator == stl_MapSerial.end())
88+
{
89+
APIHelp_IsErrorOccur = true;
90+
APIHelp_dwErrorCode = ERROR_XENGINE_MQCORE_APIHELP_COUNTER_NOTFOUND;
91+
st_Locker.unlock_shared();
92+
return false;
93+
}
94+
stl_MapIterator->second++;
95+
*pInt_Serial = stl_MapIterator->second;
96+
st_Locker.unlock_shared();
97+
return true;
98+
}
99+
/********************************************************************
100+
函数名称:APIHelp_Counter_SerialDel
101+
函数功能:删除当前队列
102+
参数.一:lpszQueueName
103+
In/Out:In
104+
类型:常量字符指针
105+
可空:N
106+
意思:输入要操作的队列名称
107+
返回值
108+
类型:逻辑型
109+
意思:是否成功
110+
备注:
111+
*********************************************************************/
112+
bool CAPIHelp_Counter::APIHelp_Counter_SerialDel(LPCXSTR lpszQueueName)
113+
{
114+
APIHelp_IsErrorOccur = false;
115+
116+
st_Locker.lock();
117+
auto stl_MapIterator = stl_MapSerial.find(lpszQueueName);
118+
if (stl_MapIterator != stl_MapSerial.end())
119+
{
120+
stl_MapSerial.erase(stl_MapIterator);
121+
}
122+
st_Locker.unlock();
123+
return true;
124+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
/********************************************************************
3+
// Created: 2025/03/11 14:45:06
4+
// File Name: D:\XEngine_MQService\XEngine_Source\MQCore_HelpModule\APIHelp_Counter\APIHelp_Counter.h
5+
// File Path: D:\XEngine_MQService\XEngine_Source\MQCore_HelpModule\APIHelp_Counter
6+
// File Base: APIHelp_Counter
7+
// File Ext: h
8+
// Project: XEngine
9+
// Author: qyt
10+
// Purpose: 帮助模块计数器
11+
// History:
12+
*********************************************************************/
13+
14+
15+
class CAPIHelp_Counter
16+
{
17+
public:
18+
CAPIHelp_Counter();
19+
~CAPIHelp_Counter();
20+
public:
21+
bool APIHelp_Counter_SerialSet(LPCXSTR lpszQueueName, __int64x nSerial);
22+
bool APIHelp_Counter_SerialGet(LPCXSTR lpszQueueName, __int64x* pInt_Serial);
23+
bool APIHelp_Counter_SerialDel(LPCXSTR lpszQueueName);
24+
protected:
25+
private:
26+
std::shared_mutex st_Locker;
27+
private:
28+
std::unordered_map<std::string, std::atomic<__int64x>> stl_MapSerial;
29+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#pragma once
2+
/********************************************************************
3+
// Created: 2025/03/11 14:47:16
4+
// File Name: D:\XEngine_MQService\XEngine_Source\MQCore_HelpModule\APIHelp_Define.h
5+
// File Path: D:\XEngine_MQService\XEngine_Source\MQCore_HelpModule
6+
// File Base: APIHelp_Define
7+
// File Ext: h
8+
// Project: XEngine
9+
// Author: qyt
10+
// Purpose: 导出的函数
11+
// History:
12+
*********************************************************************/
13+
//////////////////////////////////////////////////////////////////////////
14+
// 导出的函数
15+
//////////////////////////////////////////////////////////////////////////
16+
extern "C" XLONG APIHelp_GetLastError(int *pInt_SysError = NULL);
17+
/*************************************************************************
18+
统计计数器导出
19+
**************************************************************************/
20+
/********************************************************************
21+
函数名称:MemoryCache_DBData_DataSerialSet
22+
函数功能:设置当前序列号
23+
参数.一:lpszQueueName
24+
In/Out:In
25+
类型:常量字符指针
26+
可空:N
27+
意思:输入要插入的队列名称
28+
参数.二:nSerial
29+
In/Out:In
30+
类型:整数型
31+
可空:N
32+
意思:输入设置的队列序列号
33+
返回值
34+
类型:逻辑型
35+
意思:是否成功
36+
备注:
37+
*********************************************************************/
38+
extern "C" bool APIHelp_Counter_SerialSet(LPCXSTR lpszQueueName, __int64x nSerial);
39+
/********************************************************************
40+
函数名称:APIHelp_Counter_SerialGet
41+
函数功能:获取当前序列号
42+
参数.一:lpszQueueName
43+
In/Out:In
44+
类型:常量字符指针
45+
可空:N
46+
意思:输入要操作的队列名称
47+
参数.二:pInt_Serial
48+
In/Out:Out
49+
类型:整数型指针
50+
可空:N
51+
意思:输出当前队列序列号
52+
返回值
53+
类型:逻辑型
54+
意思:是否成功
55+
备注:
56+
*********************************************************************/
57+
extern "C" bool APIHelp_Counter_SerialGet(LPCXSTR lpszQueueName, __int64x* pInt_Serial);
58+
/********************************************************************
59+
函数名称:APIHelp_Counter_SerialDel
60+
函数功能:删除当前队列
61+
参数.一:lpszQueueName
62+
In/Out:In
63+
类型:常量字符指针
64+
可空:N
65+
意思:输入要操作的队列名称
66+
返回值
67+
类型:逻辑型
68+
意思:是否成功
69+
备注:
70+
*********************************************************************/
71+
extern "C" bool APIHelp_Counter_SerialDel(LPCXSTR lpszQueueName);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
/********************************************************************
3+
// Created: 2025/03/11 14:47:36
4+
// File Name: D:\XEngine_MQService\XEngine_Source\MQCore_HelpModule\APIHelp_Error.h
5+
// File Path: D:\XEngine_MQService\XEngine_Source\MQCore_HelpModule
6+
// File Base: APIHelp_Error
7+
// File Ext: h
8+
// Project: XEngine
9+
// Author: qyt
10+
// Purpose: 导出的错误
11+
// History:
12+
*********************************************************************/
13+
//////////////////////////////////////////////////////////////////////////
14+
// 导出的错误
15+
//////////////////////////////////////////////////////////////////////////
16+
#define ERROR_XENGINE_MQCORE_APIHELP_COUNTER_PARAMENT 0x1B0001 //创建线程失败
17+
#define ERROR_XENGINE_MQCORE_APIHELP_COUNTER_NOTFOUND 0x1B0002 //没有找到
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
LIBRARY
2+
3+
EXPORTS
4+
APIHelp_GetLastError
5+
6+
APIHelp_Counter_SerialSet
7+
APIHelp_Counter_SerialGet
8+
APIHelp_Counter_SerialDel

0 commit comments

Comments
 (0)