]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/segmented.cpp
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)
11 #include <boost/context/all.hpp>
13 namespace ctx
= boost::context
;
15 #ifdef BOOST_MSVC //MS VisualStudio
16 __declspec(noinline
) void access( char *buf
);
18 void access( char *buf
) __attribute__ ((noinline
));
20 void access( char *buf
) {
28 std::cout
<< i
<< ". iteration" << std::endl
;
35 #if defined(BOOST_USE_SEGMENTED_STACKS)
36 std::cout
<< "using segmented_stack stacks: allocates " << count
<< " * 4kB == " << 4 * count
<< "kB on stack, ";
37 std::cout
<< "initial stack size = " << boost::context::segmented_stack::traits_type::default_size() / 1024 << "kB" << std::endl
;
38 std::cout
<< "application should not fail" << std::endl
;
40 std::cout
<< "using standard stacks: allocates " << count
<< " * 4kB == " << 4 * count
<< "kB on stack, ";
41 std::cout
<< "initial stack size = " << boost::context::fixedsize_stack::traits_type::default_size() / 1024 << "kB" << std::endl
;
42 std::cout
<< "application might fail" << std::endl
;
44 ctx::continuation c
= ctx::callcc(
45 [count
](ctx::continuation
&& c
){
49 std::cout
<< "main: done" << std::endl
;