]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/v1/fibonacci.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / context / example / v1 / fibonacci.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 <memory>
10
11 #include <boost/context/all.hpp>
12
13 int main() {
14 int n=35;
15 boost::context::execution_context sink( boost::context::execution_context::current() );
16 boost::context::execution_context source(
17 [n,&sink](void*)mutable{
18 int a=0;
19 int b=1;
20 while(n-->0){
21 sink(&a);
22 auto next=a+b;
23 a=b;
24 b=next;
25 }
26 });
27 for(int i=0;i<10;++i){
28 std::cout<<*(int*)source()<<" ";
29 }
30 std::cout << "\nmain: done" << std::endl;
31 return EXIT_SUCCESS;
32 }