Remove some more code out into a separate CL.
[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 // This file defines helper functions for running LLVM in a multi-threaded
11 // environment.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SUPPORT_THREADING_H
16 #define LLVM_SUPPORT_THREADING_H
17
18 #include "llvm/Support/Mutex.h"
19
20 namespace llvm {
21
22   /// llvm_get_global_lock() - returns the llvm global lock object.
23   sys::Mutex &llvm_get_global_lock();
24
25   /// llvm_is_multithreaded() - returns true if LLVM is compiled with support
26   /// for multiple threads, and false otherwise.
27   bool llvm_is_multithreaded();
28
29   /// llvm_execute_on_thread - Execute the given \p UserFn on a separate
30   /// thread, passing it the provided \p UserData.
31   ///
32   /// This function does not guarantee that the code will actually be executed
33   /// on a separate thread or honoring the requested stack size, but tries to do
34   /// so where system support is available.
35   ///
36   /// \param UserFn - The callback to execute.
37   /// \param UserData - An argument to pass to the callback function.
38   /// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
39   /// the thread stack.
40   void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData,
41                               unsigned RequestedStackSize = 0);
42 }
43
44 #endif