9#include "thread_intf.hpp"
11#include "../utility/utility.hpp"
12#include "../char_maps/char_maps.hpp"
13#include "../macros.hpp"
17#include <unordered_map>
19hi_export_module(hikogui.concurrency.thread : impl);
21hi_export
namespace hi::inline
v1 {
26 constexpr uint64_t NT_TIB_CurrentThreadID = 0x48;
27 return __readgsdword(NT_TIB_CurrentThreadID);
33 SetThreadDescription(GetCurrentThread(), wname.c_str());
35 auto const lock = std::scoped_lock(detail::thread_names_mutex);
45 r[i] = to_bool(rhs & (DWORD_PTR{1} << i));
55 r |= rhs[i] ? (DWORD{1} << i) : 0;
62 DWORD_PTR process_mask;
63 DWORD_PTR system_mask;
65 auto process_handle = GetCurrentProcess();
67 if (not GetProcessAffinityMask(process_handle, &process_mask, &system_mask)) {
71 return mask_int_to_vec(process_mask);
76 auto const mask_ = mask_vec_to_int(mask);
78 auto const thread_handle = GetCurrentThread();
80 auto const old_mask = SetThreadAffinityMask(thread_handle, mask_);
85 return mask_int_to_vec(old_mask);
90 auto const index = GetCurrentProcessorNumber();
91 hi_assert(index < 64);
Definition of the unfair_mutex.
Rules for working with win32 headers.
constexpr std::wstring to_wstring(std::u32string_view rhs) noexcept
Conversion from UTF-32 to wide-string (UTF-16/32).
Definition to_string.hpp:160
std::vector< bool > process_affinity_mask()
Get the current process CPU affinity mask.
void set_thread_name(std::string_view name) noexcept
Set the name of the current thread.
std::vector< bool > set_thread_affinity_mask(std::vector< bool > const &mask)
Set the current thread CPU affinity mask.
std::size_t current_cpu_id() noexcept
Get the current CPU id.
thread_id current_thread_id() noexcept
Get the current thread id.
hi_export std::string get_last_error_message()
Get the OS error message from the last error received on this thread.
Definition exception_win32_impl.hpp:30
DOXYGEN BUG.
Definition algorithm_misc.hpp:20