From 698c52ee893a06b2d59ed2c1856f42c9e92afafd Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Fri, 18 Sep 2015 21:29:19 +0200 Subject: [PATCH] fix formating --- example/chained.cpp | 69 +++++++++++++++++++-------------------------- example/simple.cpp | 3 +- 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/example/chained.cpp b/example/chained.cpp index aadd9bf..14e3f0f 100644 --- a/example/chained.cpp +++ b/example/chained.cpp @@ -9,55 +9,42 @@ #include -template -struct test -{ +template< typename coroutine > +struct test { using pull_type = typename coroutine::pull_type; using push_type = typename coroutine::push_type; pull_type * child = nullptr; - void start_child_coroutine() - { - child = new pull_type - ( - [](push_type & yield) - { - std::cout << "2"; - yield(); - std::cout << "2"; - yield(); - std::cout << "2"; - yield(); - std::cout << "2"; - yield(); - std::cout << "2"; - yield(); - std::cout << "2"; - } - ); + void start_child_coroutine() { + child = new pull_type([](push_type & yield) { + std::cout << "2"; + yield(); + std::cout << "2"; + yield(); + std::cout << "2"; + yield(); + std::cout << "2"; + yield(); + std::cout << "2"; + yield(); + std::cout << "2"; + }); } - pull_type start_parent_coroutine() - { - return pull_type - ( - [this](push_type & yield) - { - std::cout << "1"; - start_child_coroutine(); - yield(); - std::cout << "1"; - } - ); + pull_type start_parent_coroutine() { + return pull_type([=](push_type & yield) { + std::cout << "1"; + start_child_coroutine(); + yield(); + std::cout << "1"; + }); } - test() - { + test() { auto parent = start_parent_coroutine(); - while (*child) - { - (*child)(); + while ( * child) { + ( * child)(); } std::cout << std::endl; } @@ -65,6 +52,8 @@ struct test int main() { - test> t2; + test< boost::coroutines2::coroutine< void > > t; std::cout << "Done" << std::endl; + + return EXIT_SUCCESS; } diff --git a/example/simple.cpp b/example/simple.cpp index bcf4bd2..0b69592 100644 --- a/example/simple.cpp +++ b/example/simple.cpp @@ -11,14 +11,13 @@ int main() { - int i = 0; boost::coroutines2::coroutine< void >::push_type sink( [&]( boost::coroutines2::coroutine< void >::pull_type & source) { std::cout << "inside coroutine-fn" << std::endl; }); sink(); - std::cout << "\nDone" << std::endl; + std::cout << "Done" << std::endl; return EXIT_SUCCESS; }