]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/v1/ontop.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / context / example / v1 / 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
10 #include <boost/context/all.hpp>
11
12 boost::context::execution_context * ctx1 = nullptr;
13 boost::context::execution_context * ctx = nullptr;
14
15 void f1( void *) {
16 std::cout << "f1: entered first time" << std::endl;
17 ( * ctx)();
18 std::cout << "f1: entered second time" << std::endl;
19 ( * ctx)();
20 std::cout << "f1: entered third time" << std::endl;
21 ( * ctx)();
22 }
23
24 void * f2( void * data) {
25 std::cout << "f2: entered" << std::endl;
26 return data;
27 }
28
29 int main() {
30 boost::context::execution_context ctx1_( f1);
31 ctx1 = & ctx1_;
32 boost::context::execution_context ctx_( boost::context::execution_context::current() );
33 ctx = & ctx_;
34
35 ( * ctx1)();
36 std::cout << "f1: returned first time" << std::endl;
37 ( * ctx1)();
38 std::cout << "f1: returned second time" << std::endl;
39 ( * ctx1)( boost::context::exec_ontop_arg, f2);
40 std::cout << "f1: returned third time" << std::endl;
41
42 std::cout << "main: done" << std::endl;
43
44 return EXIT_SUCCESS;
45 }