Skip to content

增加UDP Agent #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
070771e
HP-Socket v 3.1.1
ldcsaa Dec 24, 2013
a11bde2
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Dec 24, 2013
b47b51e
HP-Socket v3.1.1 Released
ldcsaa Dec 24, 2013
a634d16
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Dec 24, 2013
b32bd41
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Dec 24, 2013
be8bfc8
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Jan 13, 2014
e599eb9
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Dec 24, 2013
d9d1271
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Dec 24, 2013
5dc9362
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Dec 24, 2013
5ee0c2a
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Jan 14, 2014
5612564
HP-Socket v3.1.3
ldcsaa Mar 29, 2014
6447166
Merge branch 'master' of github.com:ldcsaa/HP-Socket
ldcsaa Mar 29, 2014
83eef40
clear old other language demo
ldcsaa Apr 17, 2014
0bedf04
0417
ldcsaa Apr 17, 2014
d7c3d00
0407
ldcsaa Apr 17, 2014
b81e191
0417
ldcsaa Apr 17, 2014
7b7d7f6
0417
ldcsaa Apr 17, 2014
6e8b82d
20140427
ldcsaa Apr 26, 2014
0660e92
20140427
ldcsaa Apr 26, 2014
91e7108
20140427
ldcsaa Apr 26, 2014
55489c2
20140427
ldcsaa Apr 26, 2014
4fcd78e
20140427
ldcsaa Apr 26, 2014
4d35e50
20140427
ldcsaa Apr 26, 2014
660e980
20040427
ldcsaa Apr 27, 2014
6f7595b
20040427
ldcsaa Apr 27, 2014
078861c
20140428
ldcsaa Apr 28, 2014
dee1c00
20140507
ldcsaa May 6, 2014
d07938e
delete
ldcsaa May 11, 2014
5d1ba7d
20140511
ldcsaa May 11, 2014
bbab911
20140511
ldcsaa May 11, 2014
474885c
20140526
ldcsaa May 25, 2014
c171507
20140604
ldcsaa Jun 4, 2014
96032d0
20140604
ldcsaa Jun 4, 2014
6b0e640
20140604
ldcsaa Jun 6, 2014
d731b01
20140707
ldcsaa Jul 6, 2014
d2c5ea3
20140707
ldcsaa Jul 6, 2014
d6251b0
20140707
ldcsaa Jul 7, 2014
d3e903a
20140708
ldcsaa Jul 8, 2014
20d5bca
20140708
ldcsaa Jul 8, 2014
0c478d0
20140812
ldcsaa Aug 12, 2014
455edce
20140812
ldcsaa Aug 12, 2014
2f89905
20140812
ldcsaa Aug 12, 2014
919a6c3
20140812
ldcsaa Aug 13, 2014
668dd66
20140812
ldcsaa Aug 13, 2014
9a2f863
20140812
ldcsaa Aug 13, 2014
c724890
20140812
ldcsaa Aug 13, 2014
1019f46
20141208
ldcsaa Dec 7, 2014
b95bb5f
20141208
ldcsaa Dec 7, 2014
534126a
20141208
ldcsaa Dec 7, 2014
34f9fe3
20141208
ldcsaa Dec 8, 2014
975112d
20141227
ldcsaa Dec 27, 2014
37f51ff
20141227
ldcsaa Dec 28, 2014
193f979
20150125
ldcsaa Jan 25, 2015
a46b530
20151028
ldcsaa Jan 28, 2015
2cdb396
20150129
ldcsaa Jan 29, 2015
21412dc
20150202
ldcsaa Feb 2, 2015
08fa5ca
20150203
ldcsaa Feb 3, 2015
cf7d517
20150205
ldcsaa Feb 5, 2015
a1207e2
20150209
ldcsaa Feb 9, 2015
e14ed68
20151130
Nov 30, 2015
74f6824
20151130
Nov 30, 2015
ded870d
20151130
Nov 30, 2015
c4eba2d
20151201
Dec 1, 2015
6476ca2
20160327
ldcsaa Mar 27, 2016
8bbd5be
20160327
ldcsaa Mar 27, 2016
005e154
20160401
ldcsaa Mar 31, 2016
6c78a87
20160402
ldcsaa Apr 1, 2016
1106c9c
20160409
Apr 9, 2016
587689c
20160409
Apr 9, 2016
5f312bc
20160409
Apr 9, 2016
5c46195
20160409
ldcsaa Apr 9, 2016
e3f2803
20160410
ldcsaa Apr 9, 2016
b615862
20160420
Apr 20, 2016
df83997
20160420
Apr 20, 2016
198c03e
20160421
Apr 21, 2016
0b211d4
20160421
Apr 21, 2016
7450e29
20160421
Apr 21, 2016
498460d
20160421
Apr 21, 2016
b77aee1
20160421
ldcsaa Apr 21, 2016
b78174e
1. added UDP Agent support.
hezlog Apr 25, 2016
6c4c72e
1.修正 UDP Agent 接口;
hezlog Apr 28, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
20140812
  • Loading branch information
ldcsaa committed Aug 12, 2014
commit 0c478d04b0c8b32115e73fbaf15d110a54e17ee5
13 changes: 13 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
==========================================================================================
v3.2.3 ���£�
==========================================================================================

> common-src ����
-----------------
1���Ż�ͨ�������ͬ������
2��������������Լ 10%

> ����˵����
-----------------
1��ʹ�� HP-Socket v3.2.2 ����ǰ�汾��Ӧ�ó�����԰�ȫ������ HP-Socket v3.2.3

==========================================================================================
v3.2.2 ���£�
==========================================================================================
Expand Down
39 changes: 16 additions & 23 deletions Common/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,37 @@ Module : vc-common-src
Desc : HP-Socket �� VC-Logger ���������
Usage : ����Ҫ�Ĵ����ļ����뵽��Ŀ��

==========================================================================================
v2.3.7 ���£�
==========================================================================================

1���޸� CriticalSection.h
1) ���� CSpinLock��CSpinGuard
2) ���� CInterCriSec ��Ĭ�� Spin Count Ϊ 4000
2���޸� RWLock.h
1) �� CSpinLock ȡ�� CInterCriSec ��Ϊ CRWLock �� CSWMR ��ͬ����
2) ���� ICVCondition/CCVGuardCS/CCVGuardSRW ���࣬����ʵ��������-������ģ��
3������ RingBuffer.h/.cpp�������ܶ�д������
4������ Thread.h/.cpp���̷߳�װ��

==========================================================================================
v2.3.6 ���£�
==========================================================================================

> �ֲ����������
-----------------
1���޸� RWLock.h������ VS 2005/2008
2���޸� bufferpool.cpp��memmove() �滻Ϊ memcpy()

==========================================================================================
v2.3.5 ���£�
==========================================================================================

> �ֲ����������
-----------------
1���޸� STLHelper.h������ unordered_set / unordered_map ����
2���޸� bufferpool.h��TBufferPtrMap ����Ϊ unordered_map

==========================================================================================
v2.3.4 ���£�
==========================================================================================

> �ֲ����������
-----------------
1���޸� RWLock.h�����ӷ������д�� CSlimLock
2���޸� bufferpool.h/bufferpool.cpp�������� TItemListEx
3������ SysHelper.h/SysHelper.cpp���ṩ��ȡϵͳ��Ϣ�İ�������
Expand All @@ -35,46 +42,32 @@ v2.3.4
v2.3.3 ���£�
==========================================================================================

> �ֲ����������
-----------------
1���޸� bufferpool.cpp���Ż� CBufferPool��TItemList
2���޸� STLHelper.h������ stack��queue��deque �Ļ������� typedef ����
3���޸� FuncHelper.h��FuncHelper.cpp������ VS 2013

> ���� _WIN32_WINNT Ĭ��ֵ��
-----------------
1���޸� GeneralHelper.h
4���޸� GeneralHelper.h
1) 32 λϵͳ _WIN32_WINNT Ĭ��ֵ��_WIN32_WINNT_WINXP
2) 64 λϵͳ _WIN32_WINNT Ĭ��ֵ��_WIN32_WINNT_WIN7

==========================================================================================
v2.3.2 ���£�
==========================================================================================

> ���� Buffer Pool ������ TItem/TItemList/TBuffer/CItemPool/CBufferPool��
-----------------
1������ bufferpool.h
2������ bufferpool.cpp

==========================================================================================
v2.3.1 ���£�
==========================================================================================

> ���Ӷ�д�������� CSWMR �� CRWLock��
-----------------
1������ RWLock.h
2������ RWLock.cpp

> �������£�
-----------------
1��ɾ�� CMTX/CSEM/CEvent ��ġ�operator HANDLE* &()�����������
2���޸� WaitFor.cpp���Ż���GetTimeGap32()������
3��ɾ�� CMTX/CSEM/CEvent ��ġ�operator HANDLE* &()�����������
4���޸� WaitFor.cpp���Ż���GetTimeGap32()������

==========================================================================================
v2.2.2 ���£�
==========================================================================================

> �Ż��� Win32 ���򣨷� MFC ���򣩵ļ����ԣ�
-----------------
1���޸� GeneralHelper.h
2���޸� FuncHelper.cpp
2 changes: 1 addition & 1 deletion Common/License.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright JessMA Open Source (ldcsaa@gmail.com)
*
* Version : 2.3.6
* Version : 2.3.7
* Author : Bruce Liang
* Website : http://www.jessma.org
* Project : https://github.com/ldcsaa
Expand Down
13 changes: 1 addition & 12 deletions Common/Src/CriticalSection.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright: JessMA Open Source (ldcsaa@gmail.com)
*
* Version : 2.3.5
* Version : 2.3.7
* Author : Bruce Liang
* Website : http://www.jessma.org
* Project : https://github.com/ldcsaa
Expand All @@ -21,17 +21,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/****************************************************************************
* *
* CriticalSection.cpp *
* *
* Create by : *
* Kingfisher 2003-10-15 *
* *
* Description: *
* ��װWin32�ٽ�������ͻ������ں˶��� *
****************************************************************************/

#include "stdafx.h"
#include "CriticalSection.h"
171 changes: 139 additions & 32 deletions Common/Src/CriticalSection.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright: JessMA Open Source (ldcsaa@gmail.com)
*
* Version : 2.3.5
* Version : 2.3.7
* Author : Bruce Liang
* Website : http://www.jessma.org
* Project : https://github.com/ldcsaa
Expand All @@ -21,52 +21,64 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/****************************************************************************
* *
* CriticalSection.h *
* *
* Create by : *
* Kingfisher 2003-10-15 *
* *
* Description: *
* ��װWin32�ٽ�������ͻ������ں˶��� *
****************************************************************************/

#pragma once

class CCriSec
#include <intrin.h>

#define DEFAULT_CRISEC_SPIN_COUNT 4096

#if defined (_WIN64)
#define DEFAULT_PAUSE_YIELD 32
#define DEFAULT_PAUSE_CYCLE 8192
#else
#define DEFAULT_PAUSE_YIELD 8
#define DEFAULT_PAUSE_CYCLE 4096
#endif

#ifndef YieldProcessor
#pragma intrinsic(_mm_pause)
#define YieldProcessor _mm_pause
#endif

class CInterCriSec
{
public:
CCriSec() {::InitializeCriticalSection(&m_crisec);}
~CCriSec() {::DeleteCriticalSection(&m_crisec);}
CInterCriSec(DWORD dwSpinCount = DEFAULT_CRISEC_SPIN_COUNT)
{VERIFY(::InitializeCriticalSectionAndSpinCount(&m_crisec, dwSpinCount));}
~CInterCriSec()
{::DeleteCriticalSection(&m_crisec);}

void Lock() {::EnterCriticalSection(&m_crisec);}
void Unlock() {::LeaveCriticalSection(&m_crisec);}
void Lock() {::EnterCriticalSection(&m_crisec);}
void Unlock() {::LeaveCriticalSection(&m_crisec);}
BOOL TryLock() {return ::TryEnterCriticalSection(&m_crisec);}
DWORD SetSpinCount(DWORD dwSpinCount) {return ::SetCriticalSectionSpinCount(&m_crisec, dwSpinCount);}

CRITICAL_SECTION* GetObject() {return &m_crisec;}

private:
CCriSec(const CCriSec& cs);
CCriSec operator = (const CCriSec& cs);
CInterCriSec(const CInterCriSec& cs);
CInterCriSec operator = (const CInterCriSec& cs);

private:
CRITICAL_SECTION m_crisec;
CRITICAL_SECTION m_crisec;
};

class CCriSec2
class CInterCriSec2
{
public:
CCriSec2(BOOL bInitialize = TRUE)
CInterCriSec2(DWORD dwSpinCount = DEFAULT_CRISEC_SPIN_COUNT, BOOL bInitialize = TRUE)
{
if(bInitialize)
{
m_pcrisec = new CRITICAL_SECTION;
::InitializeCriticalSection(m_pcrisec);
VERIFY(::InitializeCriticalSectionAndSpinCount(m_pcrisec, dwSpinCount));
}
else
m_pcrisec = nullptr;
}

~CCriSec2() {Reset();}
~CInterCriSec2() {Reset();}

void Attach(CRITICAL_SECTION* pcrisec)
{
Expand All @@ -81,12 +93,16 @@ class CCriSec2
return pcrisec;
}

void Lock() {::EnterCriticalSection(m_pcrisec);}
void Unlock() {::LeaveCriticalSection(m_pcrisec);}
void Lock() {::EnterCriticalSection(m_pcrisec);}
void Unlock() {::LeaveCriticalSection(m_pcrisec);}
BOOL TryLock() {return ::TryEnterCriticalSection(m_pcrisec);}
DWORD SetSpinCount(DWORD dwSpinCount) {return ::SetCriticalSectionSpinCount(m_pcrisec, dwSpinCount);}

CRITICAL_SECTION* GetObject() {return m_pcrisec;}

private:
CCriSec2(const CCriSec2& cs);
CCriSec2 operator = (const CCriSec2& cs);
CInterCriSec2(const CInterCriSec2& cs);
CInterCriSec2 operator = (const CInterCriSec2& cs);

void Reset()
{
Expand All @@ -99,7 +115,7 @@ class CCriSec2
}

private:
CRITICAL_SECTION* m_pcrisec;
CRITICAL_SECTION* m_pcrisec;
};

class CMTX
Expand Down Expand Up @@ -141,6 +157,92 @@ class CMTX
HANDLE m_hMutex;
};

class CSpinGuard
{
public:
CSpinGuard()
: m_dwThreadID (0)
, m_iCount (0)
{

}

~CSpinGuard()
{
ASSERT(m_dwThreadID == 0);
ASSERT(m_iCount == 0);
}

void Lock()
{
for(UINT i = 0; !_TryLock(i == 0); i++)
Pause(i);
}

BOOL TryLock()
{
return _TryLock(TRUE);
}

void Unlock()
{
DWORD dwCurrentThreadID = ::GetCurrentThreadId();

if(m_dwThreadID == dwCurrentThreadID)
{
if((--m_iCount) == 0)
m_dwThreadID = 0;
}
}

static void Pause(UINT i)
{
if (i < DEFAULT_PAUSE_YIELD) YieldProcessor();
else if (i < DEFAULT_PAUSE_CYCLE - 1) SwitchToThread();
else if (i < DEFAULT_PAUSE_CYCLE) Sleep(1);
else Pause(i & (DEFAULT_PAUSE_CYCLE - 1));
}

private:
CSpinGuard(const CSpinGuard& cs);
CSpinGuard operator = (const CSpinGuard& cs);

BOOL _TryLock(BOOL bFirst)
{
DWORD dwCurrentThreadID = ::GetCurrentThreadId();

if(bFirst && m_dwThreadID == dwCurrentThreadID)
{
++m_iCount;
return TRUE;
}

if(::InterlockedCompareExchange((volatile LONG*)&m_dwThreadID, dwCurrentThreadID, 0) == 0)
{
::_ReadWriteBarrier();
ASSERT(m_iCount == 0);

m_iCount = 1;

return TRUE;
}

return FALSE;
}

private:
volatile DWORD m_dwThreadID;
int m_iCount;
};

class CFakeGuard
{
public:
void Lock() {}
void Unlock() {}
BOOL TryLock() {return TRUE;}
};

template<class CLockObj> class CLocalLock
{
public:
Expand All @@ -150,6 +252,11 @@ template<class CLockObj> class CLocalLock
CLockObj& m_lock;
};

typedef CLocalLock<CCriSec> CCriSecLock;
typedef CLocalLock<CCriSec2> CCriSecLock2;
typedef CLocalLock<CMTX> CMutexLock;
typedef CInterCriSec CCriSec;

typedef CLocalLock<CCriSec> CCriSecLock;
typedef CLocalLock<CInterCriSec> CInterCriSecLock;
typedef CLocalLock<CInterCriSec2> CInterCriSecLock2;
typedef CLocalLock<CMTX> CMutexLock;
typedef CLocalLock<CSpinGuard> CSpinLock;
typedef CLocalLock<CFakeGuard> CFakeLock;
Loading