slezica/inline-parallel.c — pull request #2 by heshbaugh (2012-04-22 15:34:17+00:00)
Title: Patch to ensure that the threaded code is run.

Nested functions become invalid at the destruction of their scope. As such, and thread executing one will at best return immediately (and at worst execute garbage).

To ensure that the threaded code is run, we must first prevent the destruction of the current scope by using a do ... while loop instead of a ({ ... }) statement. Next, we must add a macro to sunchronize the work before another thread is created, or the current scope ends (i.e. a return from a function.)

This patch uses a do ... while loop for multiple statements in the threading macros, and introduces wait_for_completion, which causes the calling thread to block until the last-defined thread exits.