]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/execution_context_v2/ontop.cpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / context / example / execution_context_v2 / ontop.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 #include <tuple>
10
11 #include <boost/context/all.hpp>
12
13 namespace ctx = boost::context;
14
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);
22 }
23
24 int f2( int data) {
25 std::cout << "f2: entered: " << data << std::endl;
26 return -1;
27 }
28
29 int main() {
30 int data = 0;
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;
38
39 std::cout << "main: done" << std::endl;
40
41 return EXIT_SUCCESS;
42 }