MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / watcher_impl

Function watcher_impl

src/core/impl/system.cpp:556–574  ·  view source on GitHub ↗

return whether kill has been issued

Source from the content-addressed store, hash-verified

554
555 //! return whether kill has been issued
556 bool watcher_impl(double timeout) {
557 using namespace std::chrono;
558 microseconds timeout_due{static_cast<uint64_t>(timeout * 1e6)};
559 auto start = high_resolution_clock::now(), end = start + timeout_due;
560 for (;;) {
561#if !__DEPLOY_ON_XP_SP2__
562 std::unique_lock<std::mutex> lk(m_watcher_stop_mtx);
563 m_watcher_stop_cv.wait_until(lk, end);
564#endif
565
566 if (m_watcher_should_stop)
567 return false;
568
569 if (high_resolution_clock::now() >= end) {
570 kill_worker();
571 return true;
572 }
573 }
574 }
575
576 void kill_worker() override {
577 if (m_worker_pid) {

Callers

nothing calls this directly

Calls 1

kill_workerFunction · 0.85

Tested by

no test coverage detected