// SPDX-FileCopyrightText: Copyright 2026 Gloria Goertz, Mireille Meyer // SPDX-License-Identifier: BSD-2-Clause #include #include #include #include #include "../StringTools.hh" namespace atom { std::thread CreateThread(const std::function& function, const std::string& name) { std::thread thread { function }; auto nameWide = StdStringToWCHAR(name); const HRESULT result = SetThreadDescription(thread.native_handle(), nameWide.get()); ATOM_ASSERT(SUCCEEDED(result) || result == 0x10000000 /* TODO(Gloria): verify that it still returns this */, "SetThreadDescription failed with {}", GetLastError()); return thread; } bool IsThreadAlive(std::thread& thread) { const DWORD result = WaitForSingleObjectEx(thread.native_handle(), 0, FALSE); switch (result) { case WAIT_OBJECT_0: { return false; } case WAIT_TIMEOUT: { return true; } default: { ATOM_PANIC("WaitForSingleObjectEx for atom::IsThreadAlive failed with {}", GetLastError()); } } } }