• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 //          Copyright Oliver Kowalke 2016.
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 #include <cstdlib>
8 #include <iostream>
9 
10 #include <boost/context/fiber.hpp>
11 
12 namespace ctx = boost::context;
13 
f1(ctx::fiber && f)14 ctx::fiber f1( ctx::fiber && f) {
15     std::cout << "f1: entered first time" << std::endl;
16     f = std::move( f).resume();
17     std::cout << "f1: entered second time" << std::endl;
18     return std::move( f);
19 }
20 
main()21 int main() {
22     ctx::fiber f{ f1 };
23     f = std::move( f).resume();
24     std::cout << "f1: returned first time" << std::endl;
25     f = std::move( f).resume();
26     std::cout << "f1: returned second time" << std::endl;
27     std::cout << "main: done" << std::endl;
28     return EXIT_SUCCESS;
29 }
30