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