libcopp  1.1.0
coroutine_context_private_data_test.cpp
Go to the documentation of this file.
1 #include <cstdio>
2 #include <cstring>
3 #include <iostream>
4 
5 #include "frame/test_macros.h"
7 
10 
12 
14 public:
15  int operator()(void *priv_data) {
19 
20  copp::this_coroutine::get<test_context_private_data_context_type>()->resume();
23 
24  copp::this_coroutine::get<test_context_private_data_context_type>()->yield(&priv_data);
26 
27  CASE_EXPECT_EQ(copp::this_coroutine::get<test_context_private_data_context_type>(), priv_data);
29 
30  return 0;
31  }
32 };
33 
34 CASE_TEST(coroutine, context_private_data) {
36 
39 
42 
45  co->resume(co.get());
46 
49 }
static ptr_t create(const callback_t &runner, allocator_type &alloc, size_t stack_size=0, size_t private_buffer_size=0, size_t coroutine_size=0) UTIL_CONFIG_NOEXCEPT
create and init coroutine with specify runner and specify stack size
#define CASE_EXPECT_EQ(l, r)
Definition: test_macros.h:62
copp::coroutine_context_container< copp::allocator::default_statck_allocator > test_context_private_data_context_type
int yield(void **priv_data=UTIL_CONFIG_NULLPTR)
yield current coroutine
static int g_test_coroutine_private_data_status
coroutine container contain stack context, stack allocator and runtime fcontext
CASE_TEST(coroutine, context_private_data)
element_type * get() const UTIL_CONFIG_NOEXCEPT