| 2038 | } |
| 2039 | |
| 2040 | void PhysicsServerExample::exitPhysics() |
| 2041 | { |
| 2042 | for (int i = 0; i < MAX_MOTION_NUM_THREADS; i++) |
| 2043 | { |
| 2044 | m_args[i].m_cs2->unlock(); |
| 2045 | m_args[i].m_cs->lock(); |
| 2046 | m_args[i].m_cs->setSharedParam(0, eRequestTerminateMotion); |
| 2047 | m_args[i].m_cs->unlock(); |
| 2048 | } |
| 2049 | int numActiveThreads = MAX_MOTION_NUM_THREADS; |
| 2050 | |
| 2051 | while (numActiveThreads) |
| 2052 | { |
| 2053 | int arg0, arg1; |
| 2054 | if (m_threadSupport->isTaskCompleted(&arg0, &arg1, 0)) |
| 2055 | { |
| 2056 | numActiveThreads--; |
| 2057 | printf("numActiveThreads = %d\n", numActiveThreads); |
| 2058 | } |
| 2059 | else |
| 2060 | { |
| 2061 | b3Clock::usleep(0); |
| 2062 | } |
| 2063 | //we need to call 'stepSimulation' to make sure that |
| 2064 | //other threads get out of blocking state (workerThreadWait) |
| 2065 | stepSimulation(0); |
| 2066 | }; |
| 2067 | |
| 2068 | printf("stopping threads\n"); |
| 2069 | |
| 2070 | m_threadSupport->deleteCriticalSection(m_args[0].m_cs); |
| 2071 | m_threadSupport->deleteCriticalSection(m_args[0].m_cs2); |
| 2072 | m_threadSupport->deleteCriticalSection(m_args[0].m_cs3); |
| 2073 | m_threadSupport->deleteCriticalSection(m_args[0].m_csGUI); |
| 2074 | |
| 2075 | delete m_threadSupport; |
| 2076 | m_threadSupport = 0; |
| 2077 | |
| 2078 | //m_physicsServer.resetDynamicsWorld(); |
| 2079 | } |
| 2080 | |
| 2081 | bool PhysicsServerExample::wantsTermination() |
| 2082 | { |
no test coverage detected