| 44 | |
| 45 | struct ThreadImpl { |
| 46 | static DWORD WINAPI runThread(void* data) { |
| 47 | ThreadImpl* ptr = static_cast<ThreadImpl*>(data); |
| 48 | try { |
| 49 | unsigned long exceptionStackSize = 131072; |
| 50 | SetThreadStackGuarantee(&exceptionStackSize); |
| 51 | ptr->function(); |
| 52 | } catch (std::exception const& e) { |
| 53 | if (ptr->name.empty()) |
| 54 | Logger::error("Exception caught in Thread: {}", outputException(e, true)); |
| 55 | else |
| 56 | Logger::error("Exception caught in Thread {}: {}", ptr->name, outputException(e, true)); |
| 57 | } catch (...) { |
| 58 | if (ptr->name.empty()) |
| 59 | Logger::error("Unknown exception caught in Thread"); |
| 60 | else |
| 61 | Logger::error("Unknown exception caught in Thread {}", ptr->name); |
| 62 | } |
| 63 | ptr->stopped = true; |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | ThreadImpl(std::function<void()> function, String name) |
| 68 | : function(std::move(function)), name(std::move(name)), thread(INVALID_HANDLE_VALUE), stopped(true) {} |
nothing calls this directly
no test coverage detected