LLVM API Documentation

Threading.h
Go to the documentation of this file.
00001 //===-- llvm/Support/Threading.h - Control multithreading mode --*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // TThis file defines llvm_start_multithreaded() and friends.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_SUPPORT_THREADING_H
00015 #define LLVM_SUPPORT_THREADING_H
00016 
00017 namespace llvm {
00018   /// llvm_start_multithreaded - Allocate and initialize structures needed to
00019   /// make LLVM safe for multithreading.  The return value indicates whether
00020   /// multithreaded initialization succeeded.  LLVM will still be operational
00021   /// on "failed" return, and will still be safe for hosting threading
00022   /// applications in the JIT, but will not be safe for concurrent calls to the
00023   /// LLVM APIs.
00024   /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.
00025   bool llvm_start_multithreaded();
00026 
00027   /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM
00028   /// safe for multithreading.
00029   /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.
00030   void llvm_stop_multithreaded();
00031 
00032   /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe
00033   /// mode or not.
00034   bool llvm_is_multithreaded();
00035 
00036   /// acquire_global_lock - Acquire the global lock.  This is a no-op if called
00037   /// before llvm_start_multithreaded().
00038   void llvm_acquire_global_lock();
00039 
00040   /// release_global_lock - Release the global lock.  This is a no-op if called
00041   /// before llvm_start_multithreaded().
00042   void llvm_release_global_lock();
00043 
00044   /// llvm_execute_on_thread - Execute the given \p UserFn on a separate
00045   /// thread, passing it the provided \p UserData.
00046   ///
00047   /// This function does not guarantee that the code will actually be executed
00048   /// on a separate thread or honoring the requested stack size, but tries to do
00049   /// so where system support is available.
00050   ///
00051   /// \param UserFn - The callback to execute.
00052   /// \param UserData - An argument to pass to the callback function.
00053   /// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
00054   /// the thread stack.
00055   void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData,
00056                               unsigned RequestedStackSize = 0);
00057 }
00058 
00059 #endif