21 #ifdef LIBCOPP_MACRO_USE_SEGMENTED_STACKS
23 typedef copp::coroutine_context_container<copp::allocator::stack_allocator_split_segment> co_context_t;
33 void loop(
int times) {
34 char buffer[64 * 1024] = {0};
35 co_context_t *pco = copp::this_coroutine::get<co_context_t>();
37 std::cout <<
"context " << pco <<
" => buffer start addr " <<
reinterpret_cast<void *
>(buffer) <<
", end addr "
38 <<
reinterpret_cast<void *
>(buffer +
sizeof(buffer)) <<
"." << std::endl;
40 min_ = std::min<intptr_t>(min_, (intptr_t)buffer);
41 max_ = std::max<intptr_t>(max_, (intptr_t)(buffer +
sizeof(buffer)));
54 min_ = std::numeric_limits<intptr_t>::max();
55 max_ = std::numeric_limits<intptr_t>::min();
68 co_context_t::ptr_t co_obj1 = co_context_t::create(&runner1, 32 * 1024);
69 co_context_t::ptr_t co_obj2 = co_context_t::create(&runner2, 32 * 1024);
70 std::cout <<
"cortoutine " << co_obj1.get() <<
" created.\n" << std::endl;
71 std::cout <<
"cortoutine " << co_obj2.get() <<
" created.\n" << std::endl;
77 while (runner1.is_running_ || runner2.is_running_) {
78 if (runner1.is_running_) {
82 if (runner2.is_running_) {
88 std::cout <<
"co_obj1 stack min addr " << runner1.min_ <<
", max addr " << runner1.max_ <<
". dis "
89 << ((runner1.max_ - runner1.min_) / 1024) <<
"KB." << std::endl;
90 std::cout <<
"co_obj2 stack min addr " << runner2.min_ <<
", max addr " << runner2.max_ <<
". dis "
91 << ((runner2.max_ - runner2.min_) / 1024) <<
"KB." << std::endl;
93 puts(
"all jobs done.");
100 puts(
"split stack disabled.");