Changeset 13b1b1d for doc/papers/concurrency/examples
- Timestamp:
- Mar 20, 2019, 2:16:10 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 571bf75
- Parents:
- aa22c60
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/concurrency/examples/Format.cpp
raa22c60 r13b1b1d 5 5 struct promise_type { 6 6 char _value; 7 int g, b; 7 struct locals { 8 int g, b; 9 } * _l; 8 10 9 11 fmt_cor get_return_object() { … … 16 18 void return_void() {} 17 19 void unhandled_exception() {} 20 21 auto yield_value(locals & l) { 22 _l = &l; 23 return suspend_never(); 24 } 18 25 }; 19 26 … … 41 48 42 49 ~fmt_cor() { 43 if(_coroutine) { _coroutine.destroy(); } 50 if(_coroutine) { 51 _coroutine.destroy(); 52 if (_coroutine.promise()._l->g != 0 | _coroutine.promise()._l->b != 0) { 53 std::cout << "\n"; 54 } 55 } 44 56 } 45 57 … … 67 79 68 80 fmt_cor Fmt() { 69 int g; // = co_await fmt_cor::g();70 int b; // = co_await fmt_cor::b();81 fmt_cor::promise_type::locals l; 82 co_yield l; 71 83 for(;;) { 72 for( g = 0; g < 5;g++) {73 for( b = 0; b < 4;b++) {84 for(l.g = 0; l.g < 5; l.g++) { 85 for(l.b = 0; l.b < 4; l.b++) { 74 86 std::cout << co_await fmt_cor::get(); 75 87 }
Note: See TracChangeset
for help on using the changeset viewer.