| 448 | } |
| 449 | |
| 450 | void EngineWorker::runThreadLoop() |
| 451 | { |
| 452 | try { |
| 453 | std::mutex mutexForLoop; |
| 454 | std::unique_lock<std::mutex> lockForLoop(mutexForLoop); |
| 455 | |
| 456 | while (!_isShutdown.load()) { |
| 457 | |
| 458 | if (!_syncSimulationWithRendering && _accessState == 0) { |
| 459 | if (_isSimulationRunning.load()) { |
| 460 | _simulationCudaFacade->calcTimestep(1, false); |
| 461 | } |
| 462 | measureTPS(); |
| 463 | slowdownTPS(); |
| 464 | } |
| 465 | |
| 466 | processJobs(); |
| 467 | |
| 468 | if (_accessState == 1) { |
| 469 | _accessState = 2; |
| 470 | } |
| 471 | } |
| 472 | } catch (std::exception const& e) { |
| 473 | std::unique_lock<std::mutex> uniqueLock(_exceptionData.mutex); |
| 474 | _exceptionData.errorMessage = e.what(); |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | void EngineWorker::runSimulation() |
| 479 | { |