// SPDX-FileCopyrightText: Copyright 2026 Gloria Goertz, Mireille Meyer // SPDX-License-Identifier: BSD-2-Clause #include #include #include #include namespace atom { std::thread CreateThread(const std::function& function, const std::string& name) { std::binary_semaphore wait { 0 }; auto thread = std::thread {[=, &wait]{ pthread_setname_np(name.c_str()); wait.release(); function(); }}; wait.acquire(); return thread; } bool IsThreadAlive(std::thread& thread) { const int result = pthread_kill(thread.native_handle(), 0); switch (result) { case 0: { return true; } case ESRCH: { return false; } default: { ATOM_PANIC("pthread_kill failed with {}", result); } } } }