LLVM  10.0.0svn
thread.h
Go to the documentation of this file.
1 //===-- llvm/Support/thread.h - Wrapper for <thread> ------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This header is a wrapper for <thread> that works around problems with the
10 // MSVC headers when exceptions are disabled. It also provides llvm::thread,
11 // which is either a typedef of std::thread or a replacement that calls the
12 // function synchronously depending on the value of LLVM_ENABLE_THREADS.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_SUPPORT_THREAD_H
17 #define LLVM_SUPPORT_THREAD_H
18 
19 #include "llvm/Config/llvm-config.h"
20 
21 #if LLVM_ENABLE_THREADS
22 
23 #include <thread>
24 
25 namespace llvm {
27 }
28 
29 #else // !LLVM_ENABLE_THREADS
30 
31 #include <utility>
32 
33 namespace llvm {
34 
35 struct thread {
36  thread() {}
37  thread(thread &&other) {}
38  template <class Function, class... Args>
39  explicit thread(Function &&f, Args &&... args) {
40  f(std::forward<Args>(args)...);
41  }
42  thread(const thread &) = delete;
43 
44  void join() {}
45  static unsigned hardware_concurrency() { return 1; };
46 };
47 
48 }
49 
50 #endif // LLVM_ENABLE_THREADS
51 
52 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
std::string join(IteratorT Begin, IteratorT End, StringRef Separator)
Joins the strings in the range [Begin, End), adding Separator between the elements.
Definition: StringExtras.h:370
unsigned hardware_concurrency()
Get the number of threads that the current program can execute concurrently.
Definition: Threading.cpp:75
std::thread thread
Definition: thread.h:26
constexpr char Args[]
Key for Kernel::Metadata::mArgs.