From 9bc1b73c9e30197d18b64fb9cf09dd45eaef256b Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Fri, 16 May 2014 02:33:15 +0000 Subject: Add C API for thread yielding callback. Sometimes a LLVM compilation may take more time then a client would like to wait for. The problem is that it is not possible to safely suspend the LLVM thread from the outside. When the timing is bad it might be possible that the LLVM thread holds a global mutex and this would block any progress in any other thread. This commit adds a new yield callback function that can be registered with a context. LLVM will try to yield by calling this callback function, but there is no guaranteed frequency. LLVM will only do so if it can guarantee that suspending the thread won't block any forward progress in other LLVM contexts in the same process. Once the client receives the call back it can suspend the thread safely and resume it at another time. Related to git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208945 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/llvm-c/Core.h') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index a86079e0ec..151165e704 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -467,6 +467,7 @@ void LLVMEnablePrettyStackTrace(void); */ typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *); +typedef void (*LLVMYieldCallback)(LLVMContextRef, void *); /** * Create a new context. @@ -488,6 +489,14 @@ void LLVMContextSetDiagnosticHandler(LLVMContextRef C, LLVMDiagnosticHandler Handler, void *DiagnosticContext); +/** + * Set the yield callback function for this context. + * + * @see LLVMContext::setYieldCallback() + */ +void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, + void *OpaqueHandle); + /** * Destroy a context instance. * -- cgit v1.2.3