| 606 | } |
| 607 | |
| 608 | EngineWorkerGuard::EngineWorkerGuard(EngineWorker* worker, std::optional<std::chrono::milliseconds> const& maxDuration) |
| 609 | : _worker(worker) |
| 610 | { |
| 611 | _worker->_mutexForEngineWorkerGuard.lock(); |
| 612 | checkForException(worker->_exceptionData); |
| 613 | |
| 614 | worker->_accessState = 1; |
| 615 | |
| 616 | auto startTimepoint = std::chrono::steady_clock::now(); |
| 617 | while (worker->_accessState == 1) { |
| 618 | auto timePassed = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - startTimepoint); |
| 619 | if (maxDuration) { |
| 620 | if (timePassed > *maxDuration) { |
| 621 | _isTimeout = true; |
| 622 | break; |
| 623 | } |
| 624 | } else { |
| 625 | if (timePassed > std::chrono::seconds(7)) { |
| 626 | _isTimeout = true; |
| 627 | throw std::runtime_error("GPU worker thread is not reachable."); |
| 628 | } |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | } |
| 633 | |
| 634 | EngineWorkerGuard::~EngineWorkerGuard() |
| 635 | { |
nothing calls this directly
no outgoing calls
no test coverage detected