coroutine: intro of coroutine<>::pull_type, coroutine<>::push_type

[SVN r85058]
This commit is contained in:
Oliver Kowalke
2013-07-17 14:09:07 +00:00
parent c39d9509a4
commit 865902f9b5
22 changed files with 397 additions and 487 deletions

View File

@@ -71,8 +71,8 @@ void reschedule()
// ___________________________________________________________ //
#ifdef BOOST_COROUTINES_UNIDIRECT
typedef coroutines::pull_coroutine<void> coro_pull;
typedef coroutines::push_coroutine<void> coro_push;
typedef coroutines::coroutine<void>::pull_type coro_pull;
typedef coroutines::coroutine<void>::push_type coro_push;
#else
typedef coroutines::coroutine<void()> coro_pull;
typedef coroutines::coroutine<void()>::caller_type coro_push;

View File

@@ -12,10 +12,12 @@
#ifdef BOOST_COROUTINES_UNIDIRECT
int main()
{
boost::coroutines::pull_coroutine< int > c(
[&]( boost::coroutines::push_coroutine< int > & c) {
boost::coroutines::coroutine< int >::pull_type c(
[&]( boost::coroutines::coroutine< int >::push_type & c) {
int first = 1, second = 1;
for ( int i = 0; i < 10; ++i)
c( first);
c( second);
for ( int i = 0; i < 8; ++i)
{
int third = first + second;
first = second;
@@ -37,7 +39,9 @@ int main()
boost::coroutines::coroutine< int() > c(
[&]( boost::coroutines::coroutine< void( int) > & c) {
int first = 1, second = 1;
for ( int i = 0; i < 10; ++i)
c( first);
c( second);
for ( int i = 0; i < 8; ++i)
{
int third = first + second;
first = second;

View File

@@ -8,6 +8,8 @@
#include <cstdlib>
#include <iostream>
#include <boost/coroutine/all.hpp>
#include "tree.h"
node::ptr_t create_tree1()
@@ -32,10 +34,10 @@ node::ptr_t create_tree2()
class coro_visitor : public visitor
{
private:
boost::coroutines::push_coroutine< leaf& > & c_;
boost::coroutines::coroutine< leaf& >::push_type & c_;
public:
coro_visitor( boost::coroutines::push_coroutine< leaf& > & c) :
coro_visitor( boost::coroutines::coroutine< leaf& >::push_type & c) :
c_( c)
{}
@@ -52,15 +54,15 @@ public:
int main()
{
node::ptr_t t1 = create_tree1();
boost::coroutines::pull_coroutine< leaf& > c1(
[&]( boost::coroutines::push_coroutine< leaf & > & c) {
boost::coroutines::coroutine< leaf& >::pull_type c1(
[&]( boost::coroutines::coroutine< leaf & >::push_type & c) {
coro_visitor v( c);
t1->accept( v);
});
node::ptr_t t2 = create_tree2();
boost::coroutines::pull_coroutine< leaf& > c2(
[&]( boost::coroutines::push_coroutine< leaf & > & c) {
boost::coroutines::coroutine< leaf& >::pull_type c2(
[&]( boost::coroutines::coroutine< leaf & >::push_type & c) {
coro_visitor v( c);
t2->accept( v);
});

View File

@@ -12,7 +12,6 @@
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/coroutine/all.hpp>
#include <boost/intrusive_ptr.hpp>
# if defined(BOOST_MSVC)