fix formating

This commit is contained in:
Oliver Kowalke 2015-09-18 21:29:19 +02:00
parent 7183bb6e4c
commit 698c52ee89
2 changed files with 30 additions and 42 deletions

View File

@ -9,55 +9,42 @@
#include <boost/coroutine2/all.hpp> #include <boost/coroutine2/all.hpp>
template<typename coroutine> template< typename coroutine >
struct test struct test {
{
using pull_type = typename coroutine::pull_type; using pull_type = typename coroutine::pull_type;
using push_type = typename coroutine::push_type; using push_type = typename coroutine::push_type;
pull_type * child = nullptr; pull_type * child = nullptr;
void start_child_coroutine() void start_child_coroutine() {
{ child = new pull_type([](push_type & yield) {
child = new pull_type std::cout << "2";
( yield();
[](push_type & yield) std::cout << "2";
{ yield();
std::cout << "2"; std::cout << "2";
yield(); yield();
std::cout << "2"; std::cout << "2";
yield(); yield();
std::cout << "2"; std::cout << "2";
yield(); yield();
std::cout << "2"; std::cout << "2";
yield(); });
std::cout << "2";
yield();
std::cout << "2";
}
);
} }
pull_type start_parent_coroutine() pull_type start_parent_coroutine() {
{ return pull_type([=](push_type & yield) {
return pull_type std::cout << "1";
( start_child_coroutine();
[this](push_type & yield) yield();
{ std::cout << "1";
std::cout << "1"; });
start_child_coroutine();
yield();
std::cout << "1";
}
);
} }
test() test() {
{
auto parent = start_parent_coroutine(); auto parent = start_parent_coroutine();
while (*child) while ( * child) {
{ ( * child)();
(*child)();
} }
std::cout << std::endl; std::cout << std::endl;
} }
@ -65,6 +52,8 @@ struct test
int main() { int main() {
test<boost::coroutines2::coroutine<void>> t2; test< boost::coroutines2::coroutine< void > > t;
std::cout << "Done" << std::endl; std::cout << "Done" << std::endl;
return EXIT_SUCCESS;
} }

View File

@ -11,14 +11,13 @@
int main() int main()
{ {
int i = 0;
boost::coroutines2::coroutine< void >::push_type sink( boost::coroutines2::coroutine< void >::push_type sink(
[&]( boost::coroutines2::coroutine< void >::pull_type & source) { [&]( boost::coroutines2::coroutine< void >::pull_type & source) {
std::cout << "inside coroutine-fn" << std::endl; std::cout << "inside coroutine-fn" << std::endl;
}); });
sink(); sink();
std::cout << "\nDone" << std::endl; std::cout << "Done" << std::endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }