source: doc/papers/concurrency/examples/C++Cor-ts.cpp @ 2514d3d7

Last change on this file since 2514d3d7 was aa22c60, checked in by tdelisle <tdelisle@…>, 6 years ago

Moved c++Cor example to examples folder

  • Property mode set to 100644
File size: 732 bytes
Line 
1
2
3auto result = co_await expression;
4
5//   |  |
6//   |  |
7//  \    /
8//   \  /
9//    \/
10
11auto&& __a = expression;
12if (!__a.await_ready()) {
13        __a.await_suspend(coroutine-handle)
14        // ...suspend/resume point...
15}
16auto result = __a.await_resume();
17
18//==================================================
19
20co_yield i;
21
22//   |  |
23//   |  |
24//  \    /
25//   \  /
26//    \/
27
28co_await __promise.yield_value(i);
29
30//==================================================
31
32... coroutine() {
33        __coroutine_context* __context = new __coroutine_context{};
34        __return = __context->_promise.get_return_object();
35        co_await   __context->_promise.initial_suspend();
36
37        ...
38
39__final_suspend_label:
40        co_await __context->promise.final_suspend();
41        delete __context;
42}
Note: See TracBrowser for help on using the repository browser.