Control flow patterns
In this section, we will look at asynchronous control flow patterns and start by analyzing the sequential execution flow.
Sequential execution
Executing a set of tasks in sequence means running them one at a time, one after the other. The order of execution matters and must be preserved, because the result of a task in the list may affect the execution of the next. Figure 4.1 illustrates this concept:

Figure 4.1: An example of sequential execution flow with three tasks
There are different variations of this flow:
- Executing a set of known tasks in sequence, without propagating data across them.
- Using the output of a task as the input for the next (also known as chain, pipeline, or waterfall).
- Iterating over a collection while running an asynchronous task on each element, one after the other.
Sequential execution is usually the main cause of the callback hell problem when using asynchronous CPS.