]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/include/llvm/Support/thread.h
Fix a memory leak in if_delgroups() introduced in r334118.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / include / llvm / Support / thread.h
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 {
26 typedef std::thread thread;
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