babylon

[简体中文]

Coroutine

Principle

A coroutine mechanism implemented based on the C++20 coroutine standard. According to the standard, a coroutine function, in addition to containing the co_xxx keyword expressions, also has special requirements for its return type. These requirements can generally be divided into two main categories: one supports a single return value coroutine, commonly referred to as a task, while the other supports multiple return values, typically called a generator.

promise awaitable

The coroutine standard does not directly define the coroutine mechanism but rather abstracts and standardizes the API part of the coroutine mechanism while separating the fine-grained SPI (Service Provider Interface) part, which remains invisible to the user. The coroutine mechanism operates through the following flow: User -> API -> Compiler -> SPI -> Coroutine mechanism. The overall operation mode is:

Submodule Documentation