1 //===-- llvm/Support/thread.h - Wrapper for <thread> ------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_SUPPORT_THREAD_H
17 #define LLVM_SUPPORT_THREAD_H
19 #include "llvm/Config/llvm-config.h"
21 #if LLVM_ENABLE_THREADS
26 typedef std::thread thread
;
29 #else // !LLVM_ENABLE_THREADS
37 thread(thread
&&other
) {}
38 template <class Function
, class... Args
>
39 explicit thread(Function
&&f
, Args
&&... args
) {
40 f(std::forward
<Args
>(args
)...);
42 thread(const thread
&) = delete;
45 static unsigned hardware_concurrency() { return 1; };
50 #endif // LLVM_ENABLE_THREADS