-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame_thread_mgt.cpp
executable file
·73 lines (57 loc) · 1.17 KB
/
frame_thread_mgt.cpp
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
/*
* frame_thread_mgt.cpp
*
* Created on: 2013-2-27
* Author: jimm
*/
#include "common/common_api.h"
#include "frame_thread_mgt.h"
FRAME_NAMESPACE_BEGIN
CFrameThreadMgt::CFrameThreadMgt()
{
m_nThreadCount = 0;
memset(m_arrThreadID, 0, sizeof(m_arrThreadID));
memset(m_arrThread, 0, sizeof(m_arrThread));
}
CFrameThreadMgt::~CFrameThreadMgt()
{
}
void CFrameThreadMgt::RegistThread(int32_t nThreadID, CThread *pThread)
{
if(nThreadID <= 0 || pThread == NULL)
{
return;
}
// MUTEX_GUARD(Lock, m_stThreadMgtLock);
for(int32_t i = 0; i < m_nThreadCount; ++i)
{
if(m_arrThreadID[i] == nThreadID)
{
m_arrThread[i] = pThread;
return;
}
}
m_arrThreadID[m_nThreadCount] = nThreadID;
m_arrThread[m_nThreadCount] = pThread;
++m_nThreadCount;
}
CThread *CFrameThreadMgt::GetCurThread()
{
return GetThread((int32_t)gettid());
}
CThread *CFrameThreadMgt::GetThread(int32_t nThreadID)
{
if(nThreadID <= 0)
{
return NULL;
}
for(int32_t i = 0; i < m_nThreadCount; ++i)
{
if(m_arrThreadID[i] == nThreadID)
{
return m_arrThread[i];
}
}
return NULL;
}
FRAME_NAMESPACE_END