22 return this->
Core (0);
29 auto threadFunc = [](LPVOID lpvParam)->DWORD
41 event.Open (_T (
"START_EVENT"));
44 OutputDebugString (_T (
"Thread action is started.\n"));
47 int index = rand () % 10;
49 wsprintf (tsz, _T (
"%d(%d),"), GetCurrentThreadId (), index);
50 OutputDebugString (tsz);
55 ret = memory.
Free (lpvMem);
58 OutputDebugString (_T (
"Thread action is stopped.\n"));
64 event.
Create (_T (
"START_EVENT"), TRUE, FALSE);
67 const int numOfThreads = 48;
71 for (
auto& item : thread)
73 item.
Create (threadFunc, (LPVOID)
this);
78 HANDLE threadHandles[numOfThreads];
79 for (
int i = 0; i < numOfThreads; i++)
81 threadHandles[i] = thread[i].
GetHandle ();
89 WaitForMultipleObjects (numOfThreads, threadHandles, TRUE, INFINITE);
94 int msec =
static_cast<int>(Q.
PastTime ());
DWORD APIENTRY Write(LPCTSTR lpctszString) const
コンソールに文字を出力します。
VOID APIENTRY Format(LPCTSTR format,...) const
コンソールに文字を出力します。
イベントに関するWindowsAPIを集約したクラス
BOOL APIENTRY Create(LPCTSTR lpctszName, BOOL bManualReset, BOOL bInitialState)
イベントを作成します。
HANDLE APIENTRY GetHandle() const
継承先はこの関数でハンドルを取得します。
virtual BOOL APIENTRY Free(LPVOID lpvMem)
メモリの返却
virtual LPVOID APIENTRY Allocate(SIZE_T bytes, DWORD dwFlags=MEM_ZERO)
メモリの取得
BOOL APIENTRY Create(SIZE_T initialSize=0, SIZE_T maximumSize=0, DWORD dwOptions=0)
ヒープ領域の取得
スレッドに関するWindowsAPIを集約したクラス
BOOL APIENTRY Create(PTHREAD_START_ROUTINE function=NULL, LPVOID lpvParam=NULL, DWORD dwCreationFlag=0)
スレッドを作成します。