]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/v2/jump.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / context / example / v2 / jump.cpp
1
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)
6
7 #include <cstdlib>
8 #include <iostream>
9
10 #include <boost/context/all.hpp>
11
12 namespace ctx = boost::context;
13
14 ctx::execution_context< int > f1( ctx::execution_context< int > ctxm, int data) {
15 std::cout << "f1: entered first time: " << data << std::endl;
16 std::tie( ctxm, data) = ctxm( data + 2);
17 std::cout << "f1: entered second time: " << data << std::endl;
18 return ctxm;
19 }
20
21 int main() {
22 int data = 1;
23 ctx::execution_context< int > ctx1( f1);
24 std::tie( ctx1, data) = ctx1( data + 2);
25 std::cout << "f1: returned first time: " << data << std::endl;
26 std::tie( ctx1, data) = ctx1( data + 2);
27 std::cout << "f1: returned second time: " << data << std::endl;
28
29 std::cout << "main: done" << std::endl;
30
31 return EXIT_SUCCESS;
32 }