MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / isTaskCompleted

Method isTaskCompleted

examples/MultiThreading/b3PosixThreadSupport.cpp:146–180  ·  view source on GitHub ↗

non-blocking test if a task is completed. First implement all versions, and then enable this API

Source from the content-addressed store, hash-verified

144
145///non-blocking test if a task is completed. First implement all versions, and then enable this API
146bool b3PosixThreadSupport::isTaskCompleted(int* puiArgument0, int* puiArgument1, int timeOutInMilliseconds)
147{
148 b3Assert(m_activeThreadStatus.size());
149
150 // wait for any of the threads to finish
151 int result = sem_trywait(m_mainSemaphore);
152 if (result == 0)
153 {
154 // get at least one thread which has finished
155 int last = -1;
156 int status = -1;
157 for (int t = 0; t < int(m_activeThreadStatus.size()); ++t)
158 {
159 status = m_activeThreadStatus[t].m_status;
160 if (2 == m_activeThreadStatus[t].m_status)
161 {
162 last = t;
163 break;
164 }
165 }
166
167 b3ThreadStatus& spuStatus = m_activeThreadStatus[last];
168
169 b3Assert(spuStatus.m_status > 1);
170 spuStatus.m_status = 0;
171
172 // need to find an active spu
173 b3Assert(last >= 0);
174
175 *puiArgument0 = spuStatus.m_taskId;
176 *puiArgument1 = spuStatus.m_status;
177 return true;
178 }
179 return false;
180}
181
182///check for messages from SPUs
183void b3PosixThreadSupport::waitForResponse(int* puiArgument0, int* puiArgument1)

Callers 6

btShutDownExampleBrowserFunction · 0.80
exitPhysicsMethod · 0.80
mainFunction · 0.80
disconnectMethod · 0.80
exitPhysicsMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected