Threading.h revision 249423
1218885Sdim//===-- llvm/Support/Threading.h - Control multithreading mode --*- C++ -*-===//
2218885Sdim//
3218885Sdim//                     The LLVM Compiler Infrastructure
4218885Sdim//
5218885Sdim// This file is distributed under the University of Illinois Open Source
6218885Sdim// License. See LICENSE.TXT for details.
7218885Sdim//
8218885Sdim//===----------------------------------------------------------------------===//
9218885Sdim//
10218885Sdim// TThis file defines llvm_start_multithreaded() and friends.
11218885Sdim//
12218885Sdim//===----------------------------------------------------------------------===//
13218885Sdim
14249423Sdim#ifndef LLVM_SUPPORT_THREADING_H
15249423Sdim#define LLVM_SUPPORT_THREADING_H
16218885Sdim
17218885Sdimnamespace llvm {
18218885Sdim  /// llvm_start_multithreaded - Allocate and initialize structures needed to
19218885Sdim  /// make LLVM safe for multithreading.  The return value indicates whether
20218885Sdim  /// multithreaded initialization succeeded.  LLVM will still be operational
21218885Sdim  /// on "failed" return, and will still be safe for hosting threading
22218885Sdim  /// applications in the JIT, but will not be safe for concurrent calls to the
23218885Sdim  /// LLVM APIs.
24218885Sdim  /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.
25218885Sdim  bool llvm_start_multithreaded();
26218885Sdim
27218885Sdim  /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM
28218885Sdim  /// safe for multithreading.
29218885Sdim  /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.
30218885Sdim  void llvm_stop_multithreaded();
31218885Sdim
32218885Sdim  /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe
33218885Sdim  /// mode or not.
34218885Sdim  bool llvm_is_multithreaded();
35218885Sdim
36218885Sdim  /// acquire_global_lock - Acquire the global lock.  This is a no-op if called
37218885Sdim  /// before llvm_start_multithreaded().
38218885Sdim  void llvm_acquire_global_lock();
39218885Sdim
40218885Sdim  /// release_global_lock - Release the global lock.  This is a no-op if called
41218885Sdim  /// before llvm_start_multithreaded().
42218885Sdim  void llvm_release_global_lock();
43218885Sdim
44243830Sdim  /// llvm_execute_on_thread - Execute the given \p UserFn on a separate
45243830Sdim  /// thread, passing it the provided \p UserData.
46218885Sdim  ///
47218885Sdim  /// This function does not guarantee that the code will actually be executed
48218885Sdim  /// on a separate thread or honoring the requested stack size, but tries to do
49218885Sdim  /// so where system support is available.
50218885Sdim  ///
51218885Sdim  /// \param UserFn - The callback to execute.
52218885Sdim  /// \param UserData - An argument to pass to the callback function.
53218885Sdim  /// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
54218885Sdim  /// the thread stack.
55218885Sdim  void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData,
56218885Sdim                              unsigned RequestedStackSize = 0);
57218885Sdim}
58218885Sdim
59218885Sdim#endif
60