coroutine: support for segmented stacks added

[SVN r82840]
This commit is contained in:
Oliver Kowalke
2013-02-12 19:01:29 +00:00
parent d16dfc92e5
commit 3bf228523c
39 changed files with 2296 additions and 1251 deletions

View File

@@ -7,14 +7,10 @@
#include <cstdlib>
#include <iostream>
#include <boost/assert.hpp>
#include <boost/range.hpp>
#include <boost/coroutine/all.hpp>
typedef boost::coroutines::coroutine< int() > coro_t;
typedef boost::range_iterator< coro_t >::type iterator_t;
void fibonacci( coro_t::caller_type & c)
void fibonacci( boost::coroutines::coroutine< void( int) > & c)
{
int first = 1, second = 1;
while ( true)
@@ -28,9 +24,10 @@ void fibonacci( coro_t::caller_type & c)
int main()
{
coro_t c( fibonacci);
iterator_t it( boost::begin( c) );
BOOST_ASSERT( boost::end( c) != it);
boost::coroutines::coroutine< int() > c( fibonacci);
boost::range_iterator<
boost::coroutines::coroutine< int() >
>::type it( boost::begin( c) );
for ( int i = 0; i < 10; ++i)
{
std::cout << * it << " ";
@@ -41,3 +38,35 @@ int main()
return EXIT_SUCCESS;
}
// C++11
#if 0
int main()
{
boost::coroutines::coroutine< int() > c(
[&]( boost::coroutines::coroutine< void( int) > & c) {
int first = 1, second = 1;
while ( true)
{
int third = first + second;
first = second;
second = third;
c( third);
}
});
boost::range_iterator<
boost::coroutines::coroutine< int() >
>::type it( boost::begin( c) );
for ( int i = 0; i < 10; ++i)
{
std::cout << * it << " ";
++it;
}
std::cout << "\nDone" << std::endl;
return EXIT_SUCCESS;
}
#endif