Added example from boost.

This commit is contained in:
Nikolai Kochetov 2020-11-30 18:46:58 +03:00
parent 4f442cd8f3
commit d50a0e63e6
2 changed files with 29 additions and 0 deletions

View File

@ -29,6 +29,9 @@ target_link_libraries (string_hash_map PRIVATE dbms)
add_executable (string_hash_map_aggregation string_hash_map.cpp)
target_link_libraries (string_hash_map_aggregation PRIVATE dbms)
add_executable (context context.cpp)
target_link_libraries (context PRIVATE dbms)
add_executable (two_level_hash_map two_level_hash_map.cpp)
target_include_directories (two_level_hash_map SYSTEM BEFORE PRIVATE ${SPARSEHASH_INCLUDE_DIR})
target_link_libraries (two_level_hash_map PRIVATE dbms)

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <boost/context/fiber.hpp>
int main(int, char **)
{
namespace ctx=boost::context;
int a;
ctx::fiber source{[&a](ctx::fiber&& sink)
{
a=0;
int b=1;
while (true)
{
sink=std::move(sink).resume();
int next=a+b;
a=b;
b=next;
}
return std::move(sink);
}};
for (int j=0;j<10;++j)
{
source=std::move(source).resume();
std::cout << a << " ";
}
}