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 bar(ctx::fiber && f)14ctx::fiber bar( ctx::fiber && f) { 15 do { 16 std::cout << "bar\n"; 17 f = std::move( f).resume(); 18 } while ( f); 19 return std::move( f); 20 } 21 main()22int main() { 23 ctx::fiber f{ bar }; 24 do { 25 std::cout << "foo\n"; 26 f = std::move( f).resume(); 27 } while ( f); 28 std::cout << "main: done" << std::endl; 29 return EXIT_SUCCESS; 30 } 31