]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/fiber/fibonacci.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / context / example / fiber / fibonacci.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 <memory>
10
11 #include <boost/context/fiber.hpp>
12
13 namespace ctx = boost::context;
14
15 int main() {
16 int a;
17 ctx::fiber f{
18 [&a](ctx::fiber && f){
19 a=0;
20 int b=1;
21 for(;;){
22 f = std::move( f).resume();
23 int next=a+b;
24 a=b;
25 b=next;
26 }
27 return std::move( f);
28 }};
29 for ( int j = 0; j < 10; ++j) {
30 f = std::move( f).resume();
31 std::cout << a << " ";
32 }
33 std::cout << std::endl;
34 std::cout << "main: done" << std::endl;
35 return EXIT_SUCCESS;
36 }