Esempio n. 1
0
	virtual void release()
	{
		// We used to do Task::release(); here before fixing DE1106 (xbox pure virtual crash)
		// Release in turn causes the dependent tasks to start running
		// The problem was that between the time release was called and by the time we got to the destructor
		// The task chain would get all the way to scene finalization code which would reset the allocation pool
		// And a new task would get allocated at the same address, then we would invoke the destructor on that freshly created task
		// This could potentially cause any number of other problems, it is suprising that it only manifested itself
		// as a pure virtual crash
		PxBaseTask* saveContinuation = mCont;
		this->~PxsCMUpdateTask();
		if (saveContinuation)
			saveContinuation->removeReference();
	}
/*
* \brief Called by dispatcher after Task has been run.
*
* If you re-implement this method, you must call this base class
* version before returning.
*/
void FetchResultsTask::release()
{
	PxTask::release();

	// copy mFollowingTask into local variable, because it might be overwritten
	// as soon as mFetchResultsReady.set() is called (and before removeReference() is called on it)
	PxBaseTask* followingTask = mFollowingTask;
	mFollowingTask = NULL;

	// Allow ApexScene::fetchResults() to run (potentially unblocking game thread)
	mScene->mFetchResultsReady.set();
	
	// remove reference to the scene completion task submitted in Scene::simulate
	// this must be done after the scene's mFetchResultsReady event is set so that the
	// app's completion task can be assured that fetchResults is ready to run
	if (followingTask)
	{
		followingTask->removeReference();
	}	
}