MCPcopy Create free account
hub / github.com/chrxh/alien / EngineWorkerGuard

Method EngineWorkerGuard

source/EngineImpl/EngineWorker.cpp:608–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608EngineWorkerGuard::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
634EngineWorkerGuard::~EngineWorkerGuard()
635{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected