From 8a5e77dc8be82f3e8dbfd6e5b00188acd7f02d92 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Thu, 21 Aug 2014 16:53:53 +0200 Subject: [PATCH] add test regarding to multiple definition --- example/cpp03/asymmetric/Jamfile.v2 | 1 + example/cpp03/asymmetric/test.cpp | 32 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 example/cpp03/asymmetric/test.cpp diff --git a/example/cpp03/asymmetric/Jamfile.v2 b/example/cpp03/asymmetric/Jamfile.v2 index 8029d0f..8ec9baa 100644 --- a/example/cpp03/asymmetric/Jamfile.v2 +++ b/example/cpp03/asymmetric/Jamfile.v2 @@ -60,6 +60,7 @@ exe segmented_stack ; exe simple : simple.cpp + test.cpp ; exe unwind : unwind.cpp diff --git a/example/cpp03/asymmetric/test.cpp b/example/cpp03/asymmetric/test.cpp new file mode 100644 index 0000000..366d104 --- /dev/null +++ b/example/cpp03/asymmetric/test.cpp @@ -0,0 +1,32 @@ +#include + +typedef boost::coroutines::asymmetric_coroutine< void >::pull_type pull_coro_t; +typedef boost::coroutines::asymmetric_coroutine< void >::push_type push_coro_t; + +void foo1( push_coro_t & sink) +{ + for ( int i = 0; i < 10; ++i) + sink(); +} + +void foo2( pull_coro_t & source) +{ + while ( source) + source(); +} + +void bar() +{ + { + pull_coro_t source( foo1); + while ( source) { + source(); + } + } + { + push_coro_t sink( foo2); + for ( int i = 0; i < 10; ++i) + sink(); + } +} +