24 static unsigned __stdcall threadFuncSync(
void *
Arg) {
25 SyncThreadInfo *TI =
static_cast<SyncThreadInfo *
>(
Arg);
26 TI->UserFn(TI->UserData);
30 static unsigned __stdcall threadFuncAsync(
void *Arg) {
31 std::unique_ptr<AsyncThreadInfo>
Info(static_cast<AsyncThreadInfo *>(Arg));
37 llvm_execute_on_thread_impl(
unsigned (__stdcall *ThreadFunc)(
void *),
void *Arg,
40 HANDLE hThread = (HANDLE)::_beginthreadex(
41 NULL, StackSizeInBytes.
getValueOr(0), ThreadFunc,
Arg, 0, NULL);
47 if (JP == JoiningPolicy::Join) {
48 if (::WaitForSingleObject(hThread, INFINITE) == WAIT_FAILED) {
52 if (::CloseHandle(hThread) == FALSE) {
58 return uint64_t(::GetCurrentThreadId());
65 constexpr
DWORD MS_VC_EXCEPTION = 0x406D1388;
68 struct THREADNAME_INFO {
83 ::RaiseException(MS_VC_EXCEPTION, 0,
sizeof(info) /
sizeof(ULONG_PTR),
86 __except (EXCEPTION_EXECUTE_HANDLER) {
94 SmallString<64> Storage;
95 StringRef NameStr = Name.toNullTerminatedStringRef(Storage);
96 SetThreadName(::GetCurrentThreadId(), NameStr.data());
118 return SetThreadPriority(GetCurrentThread(),
119 Priority == ThreadPriority::Background
120 ? THREAD_MODE_BACKGROUND_BEGIN
121 : THREAD_MODE_BACKGROUND_END)
122 ? SetThreadPriorityResult::SUCCESS
123 : SetThreadPriorityResult::FAILURE;
void set_thread_name(const Twine &Name)
Set the name of the current thread.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
uint32_t get_max_thread_name_length()
Get the maximum length of a thread name on this platform.
void get_thread_name(SmallVectorImpl< char > &Name)
Get the name of the current thread.
Analysis containing CSE Info
SetThreadPriorityResult
If priority is Background tries to lower current threads priority such that it does not affect foregr...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
uint64_t get_threadid()
Return the current thread id, as used in various OS system calls.
SetThreadPriorityResult set_thread_priority(ThreadPriority Priority)
LLVM_ATTRIBUTE_NORETURN void ReportLastErrorFatal(const char *Msg)