[llvm-commits] [llvm] r118222 - in /llvm/trunk: include/llvm/System/Threading.h lib/System/Threading.cpp

Frits van Bommel fvbommel at gmail.com
Thu Nov 4 02:39:32 PDT 2010


> +void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
> +                                  unsigned RequestedStackSize) {
> +  ThreadInfo Info = { Fn, UserData };
> +  pthread_attr_t Attr;
> +  pthread_t Thread;
> +
> +  // Construct the attributes object.
> +  if (::pthread_attr_init(&Attr) != 0)
> +    return;

I'm not sure what kind of errors can occur here, but shouldn't the
threaded version fall back to a non-threaded call if there's some kind
of error?

> +  // Construct and execute the thread.
> +  if (::pthread_create(&Thread, &Attr, ExecuteOnThread_Dispatch, &Info) != 0)
> +    goto error;
> +
> +  // Wait for the thread and clean up.
> +  ::pthread_join(Thread, 0);

What's the point of running something on a separate thread if you're
just going to immediately make this thread wait for it to finish?




More information about the llvm-commits mailing list