Revert r255444.
[oota-llvm.git] / include / llvm / Support / thread.h
1 //===-- llvm/Support/thread.h - Wrapper for <thread> ------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This header is a wrapper for <thread> that works around problems with the
11 // MSVC headers when exceptions are disabled. It also provides llvm::thread,
12 // which is either a typedef of std::thread or a replacement that calls the
13 // function synchronously depending on the value of LLVM_ENABLE_THREADS.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_SUPPORT_THREAD_H
18 #define LLVM_SUPPORT_THREAD_H
19
20 #include "llvm/Config/llvm-config.h"
21
22 #if LLVM_ENABLE_THREADS
23
24 #ifdef _MSC_VER
25 // concrt.h depends on eh.h for __uncaught_exception declaration
26 // even if we disable exceptions.
27 #include <eh.h>
28
29 // Suppress 'C++ exception handler used, but unwind semantics are not enabled.'
30 #pragma warning(push)
31 #pragma warning(disable:4530)
32 #endif
33
34 #include <thread>
35
36 #ifdef _MSC_VER
37 #pragma warning(pop)
38 #endif
39
40 namespace llvm {
41 typedef std::thread thread;
42 }
43
44 #else // !LLVM_ENABLE_THREADS
45
46 namespace llvm {
47
48 struct thread {
49   thread() {}
50   thread(thread &&other) {}
51   template <class Function, class... Args>
52   explicit thread(Function &&f, Args &&... args) {
53     f(std::forward<Args>(args)...);
54   }
55   thread(const thread &) = delete;
56
57   void join() {}
58 };
59
60 }
61
62 #endif // LLVM_ENABLE_THREADS
63
64 #endif