Comments (2)
以co_await task
为例,由于Task
类的Promise
定义了await_transform
函数,因此会调用
auto task_awaiter = p. await_transform(task);
因为我的await_transform
只是简单地透传一下task
,所以
auto task_awaiter = task;
接下来就是调用task
对象的operator co_await
操作符拿到真正的awaiter
,编译器会展开awaiter
里的await_ready/await_suspend/await_resume
等函数。
感兴趣的话可以参考一下我的书,机工社《C++20高级编程》:
from asyncio.
以
co_await task
为例,由于Task
类的Promise
定义了await_transform
函数,因此会调用auto task_awaiter = p. await_transform(task);
因为我的
await_transform
只是简单地透传一下task
,所以auto task_awaiter = task;
接下来就是调用
task
对象的operator co_await
操作符拿到真正的awaiter
,编译器会展开awaiter
里的await_ready/await_suspend/await_resume
等函数。
await_transform仅是透传,concepts::Awaitable的require要求Task重载co_await,operator co_await操作符拿到真正的awaiter,明白了谢谢指教,另书已买还没到
from asyncio.
Related Issues (15)
- 单元测试报错 HOT 2
- OSX compilation troubles HOT 1
- Python: run_soon_threadsafe
- Installation error HOT 4
- Compatability with cppcoro HOT 2
- vcpkg HOT 2
- Benchmark: more options
- Can't compile it with gcc 11 HOT 3
- wait_for控制超时导致coredump HOT 7
- heap-use-after-free HOT 4
- Release test pass in GCC 11.2 :-)
- [Feature Request] TLS Support? HOT 2
- No install target?
- Just a comparison HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asyncio.