mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-28 18:23:10 +08:00
Feature: Add menu to set screen strategy for remote control
This commit is contained in:
@@ -3,18 +3,18 @@
|
||||
#pragma warning(disable: 4996)
|
||||
#pragma warning(disable: 4819)
|
||||
|
||||
// 浜掓枼閿併€佺潯鐪犲嚱鏁般€佽嚜鍔ㄩ攣銆佽嚜鍔ㄨ鏃躲€佽嚜鍔ㄦ棩蹇楃瓑
|
||||
// 互斥锁、睡眠函数、自动锁、自动计时、自动日志等
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
// 鑷姩鏃ュ織
|
||||
// 自动日志
|
||||
class CAutoLog
|
||||
{
|
||||
private:
|
||||
CRITICAL_SECTION *m_cs;
|
||||
CRITICAL_SECTION* m_cs;
|
||||
const char* name;
|
||||
public:
|
||||
CAutoLog(const char* _name, CRITICAL_SECTION *cs=NULL) : name(_name), m_cs(cs)
|
||||
CAutoLog(const char* _name, CRITICAL_SECTION* cs = NULL) : name(_name), m_cs(cs)
|
||||
{
|
||||
Mprintf(">>> Enter thread %s: [%d]\n", name ? name : "", GetCurrentThreadId());
|
||||
if (m_cs)EnterCriticalSection(m_cs);
|
||||
@@ -64,8 +64,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
CRITICAL_SECTION* m_cs; // 澶栭儴閿?
|
||||
CRITICAL_SECTION i_cs; // 鍐呴儴閿?
|
||||
CRITICAL_SECTION* m_cs; // 外部锁
|
||||
CRITICAL_SECTION i_cs; // 内部锁
|
||||
};
|
||||
|
||||
typedef CLock CLocker;
|
||||
@@ -73,7 +73,7 @@ typedef CLock CLocker;
|
||||
class CAutoLock
|
||||
{
|
||||
private:
|
||||
CRITICAL_SECTION &m_cs;
|
||||
CRITICAL_SECTION& m_cs;
|
||||
|
||||
public:
|
||||
CAutoLock(CRITICAL_SECTION& cs) : m_cs(cs)
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// 鏅鸿兘璁℃椂鍣紝璁$畻鍑芥暟鐨勮€楁椂
|
||||
// 智能计时器,计算函数的耗时
|
||||
class auto_tick
|
||||
{
|
||||
private:
|
||||
@@ -124,7 +124,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
auto_tick(const char* file_name, const char* func_name, int line_no, int th = 5, const std::string &tag="") :
|
||||
auto_tick(const char* file_name, const char* func_name, int line_no, int th = 5, const std::string& tag = "") :
|
||||
file(file_name), func(func_name), line(line_no), span(th), tick(now()), tag(tag) { }
|
||||
~auto_tick()
|
||||
{
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
if (s > span) {
|
||||
char buf[1024];
|
||||
tag.empty() ? sprintf_s(buf, "%s(%d) : [%s] cost [%d]ms.\n", file, line, func, s) :
|
||||
sprintf_s(buf, "%s(%d) : [%s] cost [%d]ms. Tag= %s. \n", file, line, func, s, tag.c_str());
|
||||
sprintf_s(buf, "%s(%d) : [%s] cost [%d]ms. Tag= %s. \n", file, line, func, s, tag.c_str());
|
||||
OutputDebugStringA(buf);
|
||||
}
|
||||
span = 0;
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
};
|
||||
|
||||
#if defined (_DEBUG) || defined (WINDOWS)
|
||||
// 鏅鸿兘璁$畻褰撳墠鍑芥暟鐨勮€楁椂锛岃秴鏃朵細鎵撳嵃
|
||||
// 智能计算当前函数的耗时,超时会打印
|
||||
#define AUTO_TICK(thresh, tag) auto_tick TICK(__FILE__, __FUNCTION__, __LINE__, thresh, tag)
|
||||
#define STOP_TICK TICK.stop()
|
||||
#else
|
||||
@@ -160,14 +160,14 @@ public:
|
||||
#include <MMSystem.h>
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
// 楂樼簿搴︾殑鐫$湢鍑芥暟
|
||||
// 高精度的睡眠函数
|
||||
#define Sleep_m(ms) { Sleep(ms); }
|
||||
|
||||
// 浠ユ闀縩姣鍦ㄦ潯浠禖涓嬬瓑寰匱绉?n鏄闀匡紝蹇呴』鑳芥暣闄?000)
|
||||
// 以步长n毫秒在条件C下等待T秒(n是步长,必须能整除1000)
|
||||
#define WAIT_n(C, T, n) { int s=(1000*(T))/(n); s=max(s,1); while((C)&&(s--))Sleep(n); }
|
||||
|
||||
// 鍦ㄦ潯浠禖鎴愮珛鏃剁瓑寰匱绉?姝ラ暱10ms)
|
||||
// 在条件C成立时等待T秒(步长10ms)
|
||||
#define WAIT(C, T) { WAIT_n(C, T, 10); }
|
||||
|
||||
// 鍦ㄦ潯浠禖鎴愮珛鏃剁瓑寰匱绉?姝ラ暱1ms)
|
||||
#define WAIT_1(C, T) { WAIT_n(C, T, 1); }
|
||||
// 在条件C成立时等待T秒(步长1ms)
|
||||
#define WAIT_1(C, T) { WAIT_n(C, T, 1); }
|
||||
Reference in New Issue
Block a user