Revert r211287, "Remove support for LLVM 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 namespace llvm {
18   /// llvm_start_multithreaded - Allocate and initialize structures needed to
19   /// make LLVM safe for multithreading.  The return value indicates whether
20   /// multithreaded initialization succeeded.  LLVM will still be operational
21   /// on "failed" return, and will still be safe for hosting threading
22   /// applications in the JIT, but will not be safe for concurrent calls to the
23   /// LLVM APIs.
24   /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.
25   bool llvm_start_multithreaded();
26
27   /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM
28   /// safe for multithreading.
29   /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.
30   void llvm_stop_multithreaded();
31
32   /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe
33   /// mode or not.
34   bool llvm_is_multithreaded();
35
36   /// llvm_execute_on_thread - Execute the given \p UserFn on a separate
37   /// thread, passing it the provided \p UserData.
38   ///
39   /// This function does not guarantee that the code will actually be executed
40   /// on a separate thread or honoring the requested stack size, but tries to do
41   /// so where system support is available.
42   ///
43   /// \param UserFn - The callback to execute.
44   /// \param UserData - An argument to pass to the callback function.
45   /// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
46   /// the thread stack.
47   void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData,
48                               unsigned RequestedStackSize = 0);
49 }
50
51 #endif