...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#include <stdio.h> int main (int argc, char ** argv) { int i = 0; finish { for(i=0; i < LG; ) { async IN(i) { // 'i' passed by copy printf("Hello %d times !\n", i); i--; // decr copy of 'i', only visible in the async body } } i++; // incr originalloop's 'i' in the spawn scope} } return 0; } |
This example shows how to create a bunch of async in a loop. The loop index 'i' is passed as an IN argument so that its value is available in the async's body.