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