17#if ( _WIN32_WINNT >= 0x0400 ) || ( _WIN32_WINDOWS > 0x0400 )
19 #error Reason "This class cannot be used by the target OS."
25#pragma comment(user,"T-Coverage Disable")
102 m_hTimer = ::CreateWaitableTimer(NULL, boIsManualReset, lpszName);
105 "CSyncWaitableTimer::CSyncWaitableTimer()",
106 "WaitableTimerが初期化できませんした。名前に問題がある可能性が有ります。"
108 if ( m_hTimer == NULL )
112 ::CancelWaitableTimer(m_hTimer);
121 VERIFY( m_hTimer = hTimer );
127 if ( m_hTimer != NULL )
129 ::CloseHandle(m_hTimer);
161 bool Start(DWORD dwLagTime, DWORD dwInterval)
163 if ( m_hTimer != NULL )
166 li.QuadPart = dwLagTime;
167 li.QuadPart *= -10000;
168 return !! ::SetWaitableTimer(m_hTimer, &li, dwInterval, NULL, 0, FALSE);
179 if ( m_hTimer != NULL )
181 ::CancelWaitableTimer(m_hTimer);
193#pragma comment(user,"T-Coverage Enable")
199DWORD WINAPI DoThread(DWORD ThreadCount)
201 for (
int i=0;i<5;i++)
204 TRACE1(
"スレッド%d: 処理開始\n", ThreadCount);
205 Sleep(400*ThreadCount);
206 TRACE1(
"スレッド%d: 処理終了\n", ThreadCount);
216 for (
int i=0; i<2; i++)
218 hThread[i] = CreateThread(
219 NULL, 0, (LPTHREAD_START_ROUTINE)DoThread,
220 (LPVOID)i,0,&ThreadID[i]);
223 s_timer.
Start(1000,1000);
224 WaitForMultipleObjects(2, hThread, TRUE, INFINITE);
225 CloseHandle(hThread[0]);
226 CloseHandle(hThread[1]);
228 typedef LONG (WINAPI *P_InterlockedCompareExchange)(LONG*,LONG,LONG);
229 typedef HANDLE (WINAPI *P_IcmpCreateFile)(VOID);
234 LONG l2 = func1()(&l1,1,0);
CSyncWaitableTimer(bool boIsManualReset=false, LPCTSTR lpszName=NULL)
コンストラクタ
void ToLock(void)
[排他] ロック状態にする.
CSyncWaitableTimer(HANDLE hTimer)
コンストラクタ
bool Start(DWORD dwLagTime, DWORD dwInterval)
[排他] 開始
virtual HANDLE GetHandle(void) const
[取得] ハンドル取得
virtual void Unlock(void) const
[排他] アンロック.
virtual ~CSyncWaitableTimer(void)
デストラクタ
#define EXCLUSIVE(CLS)
簡易排他制御マクロ.