mirror of
https://github.com/boostorg/coroutine.git
synced 2026-01-30 19:52:18 +00:00
renamic coroutine<> -> asymmetric_coroutine<>
This commit is contained in:
44
example/cpp03/asymmetric/unwind.cpp
Normal file
44
example/cpp03/asymmetric/unwind.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2009.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/coroutine/all.hpp>
|
||||
|
||||
struct X : private boost::noncopyable
|
||||
{
|
||||
X() { std::cout << "X()" << std::endl; }
|
||||
~X() { std::cout << "~X()" << std::endl; }
|
||||
};
|
||||
|
||||
void fn( boost::coroutines::coroutine< void >::push_type & sink)
|
||||
{
|
||||
X x;
|
||||
int i = 0;
|
||||
while ( true)
|
||||
{
|
||||
std::cout << "fn() : " << ++i << std::endl;
|
||||
sink();
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char * argv[])
|
||||
{
|
||||
{
|
||||
boost::coroutines::coroutine< void >::pull_type source( fn);
|
||||
for ( int k = 0; k < 3; ++k)
|
||||
{
|
||||
source();
|
||||
}
|
||||
std::cout << "destroying coroutine and unwinding stack" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "\nDone" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user