Add logger.h and locker.h
This commit is contained in:
@@ -373,47 +373,6 @@ public:
|
||||
|
||||
typedef IOCPServer ISocketBase;
|
||||
|
||||
class CLock
|
||||
{
|
||||
public:
|
||||
CLock(CRITICAL_SECTION& cs) : m_cs(&cs)
|
||||
{
|
||||
Lock();
|
||||
}
|
||||
CLock() : m_cs(nullptr)
|
||||
{
|
||||
InitializeCriticalSection(&i_cs);
|
||||
}
|
||||
~CLock()
|
||||
{
|
||||
m_cs ? Unlock() : DeleteCriticalSection(&i_cs);
|
||||
}
|
||||
|
||||
void Unlock()
|
||||
{
|
||||
LeaveCriticalSection(m_cs ? m_cs : &i_cs);
|
||||
}
|
||||
|
||||
void Lock()
|
||||
{
|
||||
EnterCriticalSection(m_cs ? m_cs : &i_cs);
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
LeaveCriticalSection(m_cs ? m_cs : &i_cs);
|
||||
}
|
||||
|
||||
void lock()
|
||||
{
|
||||
EnterCriticalSection(m_cs ? m_cs : &i_cs);
|
||||
}
|
||||
|
||||
protected:
|
||||
CRITICAL_SECTION* m_cs; // <20>ⲿ<EFBFBD><E2B2BF>
|
||||
CRITICAL_SECTION i_cs; // <20>ڲ<EFBFBD><DAB2><EFBFBD>
|
||||
};
|
||||
|
||||
#define TRACK_OVERLAPPEDPLUS 0
|
||||
|
||||
class OVERLAPPEDPLUS
|
||||
|
||||
@@ -20,12 +20,6 @@
|
||||
#define VC_EXTRALEAN // <20><> Windows ͷ<><CDB7><EFBFBD>ų<EFBFBD><C5B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define Mprintf(format, ...) TRACE(format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define Mprintf(format, ...)
|
||||
#endif
|
||||
|
||||
// <20>Ƴ<EFBFBD><C6B3>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>MFC<46>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD>֣<EFBFBD><D6A3><EFBFBD>С<EFBFBD><D0A1>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С
|
||||
#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS
|
||||
|
||||
@@ -117,47 +111,9 @@ enum
|
||||
#include <MMSystem.h>
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
// <20>߾<EFBFBD><DFBE>ȵ<EFBFBD>˯<EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD>
|
||||
#define Sleep_m(ms) { timeBeginPeriod(1); Sleep(ms); timeEndPeriod(1); }
|
||||
|
||||
// <20>Բ<EFBFBD><D4B2><EFBFBD>n<EFBFBD><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD>µȴ<C2B5>T<EFBFBD><54>(n<>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1000)
|
||||
#define WAIT_n(C, T, n) {assert(!(1000%(n)));int s=(1000*(T))/(n);do{Sleep(n);}while((C)&&(--s));}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>T<EFBFBD><54>(<28><><EFBFBD><EFBFBD>10ms)
|
||||
#define WAIT(C, T) { timeBeginPeriod(1); WAIT_n(C, T, 10); timeEndPeriod(1); }
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>T<EFBFBD><54>(<28><><EFBFBD><EFBFBD>1ms)
|
||||
#define WAIT_1(C, T) { timeBeginPeriod(1); WAIT_n(C, T, 1); timeEndPeriod(1); }
|
||||
|
||||
// <20><><EFBFBD>ܼ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㺯<EFBFBD><E3BAAF><EFBFBD>ĺ<EFBFBD>ʱ
|
||||
class auto_tick
|
||||
{
|
||||
private:
|
||||
const char *func;
|
||||
int span;
|
||||
clock_t tick;
|
||||
__inline clock_t now() const { return clock(); }
|
||||
__inline int time() const { return now() - tick; }
|
||||
|
||||
public:
|
||||
auto_tick(const char *func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
|
||||
~auto_tick() { stop(); }
|
||||
|
||||
__inline void stop() {
|
||||
if (span != 0) { int s(this->time()); if (s > span)TRACE("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s); span = 0; }
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
|
||||
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
||||
#define STOP_TICK TICK.stop()
|
||||
#else
|
||||
#define AUTO_TICK(thresh)
|
||||
#define STOP_TICK
|
||||
#endif
|
||||
|
||||
#define SAFE_DELETE(p) if(p){ delete (p); (p) = NULL; }
|
||||
#define SAFE_DELETE_ARRAY(p) if(p){ delete[] (p); (p) = NULL; }
|
||||
|
||||
#include "common/logger.h"
|
||||
#include "common/locker.h"
|
||||
#include "common/commands.h"
|
||||
|
||||
Reference in New Issue
Block a user