mirror of
https://github.com/boostorg/coroutine.git
synced 2026-02-10 11:22:32 +00:00
coroutine: activate new interface V2
[SVN r84428]
This commit is contained in:
@@ -10,6 +10,40 @@
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/coroutine/all.hpp>
|
||||
|
||||
#ifdef BOOST_COROUTINES_V2
|
||||
struct X : private boost::noncopyable
|
||||
{
|
||||
X() { std::cout << "X()" << std::endl; }
|
||||
~X() { std::cout << "~X()" << std::endl; }
|
||||
};
|
||||
|
||||
void fn( boost::coroutines::push_coroutine< void > & c)
|
||||
{
|
||||
X x;
|
||||
int i = 0;
|
||||
while ( true)
|
||||
{
|
||||
std::cout << "fn() : " << ++i << std::endl;
|
||||
c();
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char * argv[])
|
||||
{
|
||||
{
|
||||
boost::coroutines::pull_coroutine< void > c( fn);
|
||||
for ( int k = 0; k < 3; ++k)
|
||||
{
|
||||
c();
|
||||
}
|
||||
std::cout << "destroying coroutine and unwinding stack" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "\nDone" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#else
|
||||
typedef boost::coroutines::coroutine< void() > coro_t;
|
||||
|
||||
struct X : private boost::noncopyable
|
||||
@@ -44,3 +78,4 @@ int main( int argc, char * argv[])
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user