[llvm-commits] [llvm] r72151 - in /llvm/trunk: include/llvm/Support/ManagedStatic.h lib/Support/ManagedStatic.cpp

Chris Lattner clattner at apple.com
Wed May 20 13:43:44 PDT 2009


On May 19, 2009, at 5:39 PM, Owen Anderson wrote:

> Author: resistor
> Date: Tue May 19 19:39:20 2009
> New Revision: 72151
>
> URL: http://llvm.org/viewvc/llvm-project?rev=72151&view=rev
> Log:
> Add llvm_start_multithreaded(), which starts up the LLVM internals  
> in thread-safe mode.  Provide double-check locking
> initialization of ManagedStatic's when running in thread-safe mode.

This looks great!
>
> +void llvm::llvm_start_multithreaded() {
> +#if LLVM_MULTITHREADED
> +  assert(ManagedStaticMutex == 0 && "Multithreaded LLVM already  
> initialized!");
> +  ManagedStaticMutex = new sys::Mutex(true);
> +#else
> +  assert(0 && "LLVM built without multithreading support!");
> +#endif
> +}

How about making llvm_start_multithreaded return a bool indicating  
whether or not it was successful?  This way clients could detect and  
nicely report the error if multithreading wasn't enabled properly.

Thanks Owen,

-Chris



More information about the llvm-commits mailing list