coroutine: activate new interface V2

[SVN r84428]
This commit is contained in:
Oliver Kowalke
2013-05-22 20:15:43 +00:00
parent bcae158775
commit ce1270c353
25 changed files with 5903 additions and 179 deletions

View File

@@ -10,6 +10,43 @@
#include <boost/bind.hpp>
#include <boost/coroutine/all.hpp>
#ifdef BOOST_COROUTINES_V2
typedef boost::coroutines::pull_coroutine< void > pull_coro_t;
typedef boost::coroutines::push_coroutine< void > push_coro_t;
void echo( pull_coro_t & c, int i)
{
std::cout << i;
c();
}
void runit( push_coro_t & ca)
{
std::cout << "started! ";
for ( int i = 0; i < 10; ++i)
{
push_coro_t c( boost::bind( echo, _1, i) );
while ( c)
c();
ca();
}
}
int main( int argc, char * argv[])
{
{
pull_coro_t c( runit);
while ( c) {
std::cout << "-";
c();
}
}
std::cout << "\nDone" << std::endl;
return EXIT_SUCCESS;
}
#else
typedef boost::coroutines::coroutine< void() > coro_t;
void echo( coro_t & ca, int i)
@@ -44,3 +81,4 @@ int main( int argc, char * argv[])
return EXIT_SUCCESS;
}
#endif