2 // Copyright Oliver Kowalke 2014.
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)
11 #include <boost/context/execution_context.hpp>
13 namespace ctx = boost::context;
15 ctx::execution_context< int > f1( ctx::execution_context< int > && ctx, int data) {
16 std::cout << "f1: entered first time: " << data << std::endl;
17 std::tie( ctx, data) = ctx( data + 1);
18 std::cout << "f1: entered second time: " << data << std::endl;
19 std::tie( ctx, data) = ctx( data + 1);
20 std::cout << "f1: entered third time: " << data << std::endl;
21 return std::move( ctx);
25 std::cout << "f2: entered: " << data << std::endl;
31 ctx::execution_context< int > ctx( f1);
32 std::tie( ctx, data) = ctx( data + 1);
33 std::cout << "f1: returned first time: " << data << std::endl;
34 std::tie( ctx, data) = ctx( data + 1);
35 std::cout << "f1: returned second time: " << data << std::endl;
36 std::tie( ctx, data) = ctx( ctx::exec_ontop_arg, f2, data + 1);
37 std::cout << "f1: returned third time" << std::endl;
39 std::cout << "main: done" << std::endl;