]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/ontop.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / context / example / ontop.cpp
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 #include <tuple>
10
11 #include <boost/context/continuation.hpp>
12
13 namespace ctx = boost::context;
14
15 int main() {
16 int data = 0;
17 ctx::continuation c = ctx::callcc( [&data](ctx::continuation && c) {
18 std::cout << "f1: entered first time: " << data << std::endl;
19 data += 1;
20 c = c.resume();
21 std::cout << "f1: entered second time: " << data << std::endl;
22 data += 1;
23 c = c.resume();
24 std::cout << "f1: entered third time: " << data << std::endl;
25 return std::move( c);
26 });
27 std::cout << "f1: returned first time: " << data << std::endl;
28 data += 1;
29 c = c.resume();
30 std::cout << "f1: returned second time: " << data << std::endl;
31 data += 1;
32 c = c.resume_with( [&data](ctx::continuation && c){
33 std::cout << "f2: entered: " << data << std::endl;
34 data = -1;
35 return std::move( c);
36 });
37 std::cout << "f1: returned third time" << std::endl;
38 std::cout << "main: done" << std::endl;
39 return EXIT_SUCCESS;
40 }