MCPcopy Create free account
hub / github.com/c3d/tao3D / WaitingThread

Function WaitingThread

libcryptopp/cryptopp/wait.cpp:145–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145DWORD WINAPI WaitingThread(LPVOID lParam)
146{
147 std::auto_ptr<WaitingThreadData> pThread((WaitingThreadData *)lParam);
148 WaitingThreadData &thread = *pThread;
149 std::vector<HANDLE> handles;
150
151 while (true)
152 {
153 thread.waitingToWait = true;
154 ::WaitForSingleObject(thread.startWaiting, INFINITE);
155 thread.waitingToWait = false;
156
157 if (thread.terminate)
158 break;
159 if (!thread.count)
160 continue;
161
162 handles.resize(thread.count + 1);
163 handles[0] = thread.stopWaiting;
164 std::copy(thread.waitHandles, thread.waitHandles+thread.count, handles.begin()+1);
165
166 DWORD result = ::WaitForMultipleObjects((DWORD)handles.size(), &handles[0], FALSE, INFINITE);
167
168 if (result == WAIT_OBJECT_0)
169 continue; // another thread finished waiting first, so do nothing
170 SetEvent(thread.stopWaiting);
171 if (!(result > WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + handles.size()))
172 {
173 assert(!"error in WaitingThread"); // break here so we can see which thread has an error
174 *thread.error = ::GetLastError();
175 }
176 }
177
178 return S_OK; // return a value here to avoid compiler warning
179}
180
181void WaitObjectContainer::CreateThreads(unsigned int count)
182{

Callers

nothing calls this directly

Calls 3

resizeMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected