]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/coroutine/example/asymmetric/parallel.cpp
2 // Copyright Oliver Kowalke 2009.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
10 #include <boost/bind.hpp>
11 #include <boost/coroutine/all.hpp>
13 void first( boost::coroutines::asymmetric_coroutine
< void >::push_type
& sink
)
15 std::cout
<< "started first! ";
16 for ( int i
= 0; i
< 10; ++i
)
19 std::cout
<< "a" << i
;
23 void second( boost::coroutines::asymmetric_coroutine
< void >::push_type
& sink
)
25 std::cout
<< "started second! ";
26 for ( int i
= 0; i
< 10; ++i
)
29 std::cout
<< "b" << i
;
33 int main( int argc
, char * argv
[])
36 boost::coroutines::asymmetric_coroutine
< void >::pull_type
source1( boost::bind( first
, _1
) );
37 boost::coroutines::asymmetric_coroutine
< void >::pull_type
source2( boost::bind( second
, _1
) );
38 while ( source1
&& source2
) {
46 std::cout
<< "\nDone" << std::endl
;