Task

Task

Is a running instance of the Thread, and includes all relevant in-memory context and variables, plus loaded, runnable instructions.

A task is the same as a class with respect to creation and destruction, as in:

  • When a task is created, the appropriate task constructor and any base-class constructors are executed in the normal order by the creating thread.
  • A task terminates when its main routine terminates. When a task terminates, so does the task’s thread of control and execution state.
  • Once a task is declared it has no special relationship with its declarer other than what results from the normal scope rules.
  • Like a coroutine, a task can access all the external variables of a C++ program and the heap

  • The member routine yield gives up control of the CPU to another ready task the specified number of times.
  • One task cannot yield another task; a task can only yield itself.