MCPcopy Create free account
hub / github.com/AlSch092/UltimateAntiCheat / ~Thread

Method ~Thread

Process/Thread.hpp:37–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 }
36
37 ~Thread()
38 {
39 Logger::logf(Info, "Ending thread which originally executed at: %llX", this->ExecutionAddress);
40
41 if (this->t.joinable())
42 {
43 this->ShutdownSignalled = true;
44
45 auto start = std::chrono::high_resolution_clock::now(); //timeout timer
46
47 while (this->t.joinable())
48 {
49
50 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::high_resolution_clock::now() - start).count() >= 10) // If 10 seconds have passed, exit the loop
51 {
52 Logger::logf(Warning, "Thread did not finish execution within the timeout period.");
53 break;
54 }
55
56 // Allow the thread some time to finish by sleeping for a short period (you could adjust this as needed)
57 std::this_thread::sleep_for(std::chrono::milliseconds(100));
58 }
59
60 if (this->t.joinable())
61 {
62 this->t.join(); //wait for the thread to finish if still running
63 }
64 }
65 }
66
67 Thread(Thread&&) = delete; //delete move constructr
68 Thread& operator=(Thread&&) noexcept = default; //delete move assignment operator

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected