Loading…
|
Translation changed |
|
|
String added in the repository |
|
Loading…
|
Translation changed |
|
|
String added in the repository |
|
Because completion handlers cause an inversion of the flow of control, sometimes other methods of attaching a continuation are desired. Networking provides the [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3747.pdf ['Universal Model for Asynchronous Operations]], providing a customizable means for transforming the signature of the initiating function to use other types of objects and methods in place of a completion handler callback. For example to call to write a string to a socket asynchronously, using a `std::future` to receive the number of bytes transferred thus looks like this:由于完成处理器会导致控制流反转,有时需要其他方式来附加延续。网络库提供 [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3747.pdf [异步操作通用模型]],该模型提供一种可定制的方法,用于改变发起函数的签名,以便使用其他类型的对象和方法来替代完成处理器回调。例如,使用 `std::future` 接收传输字节数来异步向套接字写入字符串的调用方式如下: