16 #include "llvm/Config/config.h"
26 #if LLVM_ENABLE_THREADS != 0
33 #if LLVM_ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)
37 void (*UserFn)(
void *);
47 unsigned RequestedStackSize) {
53 if (::pthread_attr_init(&Attr) != 0)
57 if (RequestedStackSize != 0) {
58 if (::pthread_attr_setstacksize(&Attr, RequestedStackSize) != 0)
67 ::pthread_join(Thread,
nullptr);
70 ::pthread_attr_destroy(&Attr);
72 #elif LLVM_ENABLE_THREADS!=0 && defined(LLVM_ON_WIN32)
86 static unsigned __stdcall ThreadCallback(
void *param) {
88 info->func(info->param);
94 unsigned RequestedStackSize) {
97 HANDLE hThread = (HANDLE)::_beginthreadex(NULL,
98 RequestedStackSize, ThreadCallback,
107 (void)::WaitForSingleObject(hThread, INFINITE);
108 ::CloseHandle(hThread);
114 unsigned RequestedStackSize) {
115 (void) RequestedStackSize;
122 #if !LLVM_ENABLE_THREADS
126 if (NumPhysical == -1)
127 return thread::hardware_concurrency();
unsigned heavyweight_hardware_concurrency()
Get the amount of currency to use for tasks requiring significant memory or other resources...
static void * ExecuteOnThread_Dispatch(void *Arg)
int getHostNumPhysicalCores()
Get the number of physical cores (as opposed to logical cores returned from thread::hardware_concurre...
bool llvm_is_multithreaded()
Returns true if LLVM is compiled with support for multi-threading, and false otherwise.
void llvm_execute_on_thread(void(*UserFn)(void *), void *UserData, unsigned RequestedStackSize=0)
llvm_execute_on_thread - Execute the given UserFn on a separate thread, passing it the provided UserD...