|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
The initiating function definition itself is straightforward. We perform type checking on the parameters, and then let `net::async_initiate` capture the parameter list along with a copy of our initiation function object. Depending on the specialization of `async_result` for the type of `CompletionToken`, the initiation function may be invoked immediately. Alternatively, it may be invoked later, after the initiating function returns. This is known as "lazy execution," and allows efficient and expressive abstractions to be written.发起函数的定义本身并不复杂:先对参数进行类型检查,再通过 `net::async_initiate` 捕获参数列表和发起函数对象的一个副本。根据 `CompletionToken` 类型对应的 `async_result` 特化版本,发起函数可以立即执行,也可以在发起函数返回之后再执行。后者称为“延迟执行”,这种机制便于编写高效且表达力强的抽象。