Remove support for runtime multi-threading.
[oota-llvm.git] / include / llvm / Support / Threading.h
1 //===-- llvm/Support/Threading.h - Control multithreading mode --*- 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 // TThis file defines llvm_start_multithreaded() and friends.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SUPPORT_THREADING_H
15 #define LLVM_SUPPORT_THREADING_H
16
17 #include "llvm/Config/llvm-config.h"
18 #include "llvm/Support/Compiler.h"
19 #include <mutex>
20
21 namespace llvm {
22
23 #if LLVM_ENABLE_THREADS != 0
24   typedef std::mutex mutex;
25   typedef std::recursive_mutex recursive_mutex;
26 #else
27   class null_mutex {
28   public:
29     void lock() { }
30     void unlock() { }
31     bool try_lock() { return true; }
32   };
33   typedef null_mutex mutex;
34   typedef null_mutex recursive_mutex;
35 #endif
36
37   /// llvm_get_global_lock() - returns the llvm global lock object.
38   llvm::recursive_mutex &llvm_get_global_lock();
39
40   /// llvm_is_multithreaded() - returns true if LLVM is compiled with support
41   /// for multiple threads, and false otherwise.
42   bool llvm_is_multithreaded();
43
44   /// llvm_execute_on_thread - Execute the given \p UserFn on a separate
45   /// thread, passing it the provided \p UserData.
46   ///
47   /// This function does not guarantee that the code will actually be executed
48   /// on a separate thread or honoring the requested stack size, but tries to do
49   /// so where system support is available.
50   ///
51   /// \param UserFn - The callback to execute.
52   /// \param UserData - An argument to pass to the callback function.
53   /// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
54   /// the thread stack.
55   void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData,
56                               unsigned RequestedStackSize = 0);
57 }
58
59 #endif