Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HC keywords in a nutshell:
  • async: asynchronously start a new task to execute a statement.
  • finish: execute a statement, but wait until all (transitively) spawned asyncs in statement's scope have terminated.


Code Block
languagecpp
titleHC HelloWorld
linenumberstrue
#include <stdio.h>
int main (int argc, char ** argv) {
  finish {
    async {
      printf("Hello World !\n");
    }
  }
  return 0;
}

In this simple example, we create an asynchronous task using an async block, which contains the code to display "HelloWorld". A finish block wraps the async which allows to wait for its complete execution before proceeding to the return statement.