Esempio n. 1
0
void btThreadPool::resizeThreads(int numThreads) {
	if (numThreads == m_numThreads) return;
	btAssert(numThreads > 0); // Don't allow the user to resize the thread count to below 0 or 0 - use stopThreads instead

	btAssert(!m_bRunningTasks); // Don't modify this if we're running tasks!!!

	if (numThreads < m_numThreads) {
		for (int i = m_numThreads - 1; i >= numThreads; i--) {
			endThread(m_pThreadInfo[i]);
			btFree(m_pThreadInfo[i]);

			m_pThreadInfo.pop_back();
		}
	} else {
		// More threads!
		m_pThreadInfo.resize(numThreads); // FYI: This doesn't actually change the thread info location since threads still need it!
		
		for (int i = m_numThreads; i < numThreads; i++) {
			m_pThreadInfo[i] = (btThreadPoolInfo *)btAlloc(sizeof(btThreadPoolInfo));
			btThreadPoolInfo *pInfo = m_pThreadInfo[i];
			pInfo->threadId = i;

			beginThread(pInfo);
		}
	}
	
	m_numThreads = numThreads;
}
btParallelCollisionDispatcher::~btParallelCollisionDispatcher() {
	m_pTaskPool->~btPoolAllocator();
	btFree(m_pTaskPool);

	btDeleteCriticalSection(m_pPoolCritSect);
	btDeleteCriticalSection(m_pAlgoPoolSect);
}
void btParallelCollisionDispatcher::freeTask(void *ptr) {
	if (!m_pTaskPool->validPtr(ptr)) {
		btFree(ptr);
	} else {
		m_pTaskPool->freeMemory(ptr);
	}
}
Esempio n. 4
0
void symbolTableDispose(tSymbolTable* symbolTable){//je treba tyhle veci delat kdyz mame mmu?
    if (symbolTable==NULL) return;
    //projit stromem a zavolat functionDispose - zatim je tu memory leak
    btFree(&(symbolTable->functions));
    mmuFree(symbolTable);
    symbolTable=NULL;

}
Esempio n. 5
0
void btThreadPool::stopThreads() {
	btAssert(m_bThreadsStarted);
	btAssert(!m_bRunningTasks); // Don't modify this if we're running tasks!!!

	m_bThreadsStarted = false;

	for (int i = 0; i < m_numThreads; i++) {
		endThread(m_pThreadInfo[i]);
		btFree(m_pThreadInfo[i]);
	}
}