MCPcopy Create free account
hub / github.com/boostorg/asio / defer_function_test

Function defer_function_test

test/defer.cpp:115–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void defer_function_test()
116{
117 io_context ctx(1);
118
119 function_count = 0;
120 int handler_count = 0;
121 defer(void_function, ctx.get_executor(),
122 bindns::bind(void_handler, &handler_count));
123
124 BOOST_ASIO_CHECK(function_count == 0);
125 BOOST_ASIO_CHECK(handler_count == 0);
126
127 ctx.run();
128
129 BOOST_ASIO_CHECK(function_count == 1);
130 BOOST_ASIO_CHECK(handler_count == 1);
131
132 function_count = 0;
133 handler_count = 0;
134 defer(void_function, ctx, bindns::bind(void_handler, &handler_count));
135
136 BOOST_ASIO_CHECK(function_count == 0);
137 BOOST_ASIO_CHECK(handler_count == 0);
138
139 ctx.restart();
140 ctx.run();
141
142 BOOST_ASIO_CHECK(function_count == 1);
143 BOOST_ASIO_CHECK(handler_count == 1);
144
145 function_count = 0;
146 handler_count = 0;
147 defer(void_function_object(), ctx.get_executor(),
148 bindns::bind(void_handler, &handler_count));
149
150 BOOST_ASIO_CHECK(function_count == 0);
151 BOOST_ASIO_CHECK(handler_count == 0);
152
153 ctx.restart();
154 ctx.run();
155
156 BOOST_ASIO_CHECK(function_count == 1);
157 BOOST_ASIO_CHECK(handler_count == 1);
158
159 function_count = 0;
160 handler_count = 0;
161 defer(void_function_object(), ctx,
162 bindns::bind(void_handler, &handler_count));
163
164 BOOST_ASIO_CHECK(function_count == 0);
165 BOOST_ASIO_CHECK(handler_count == 0);
166
167 ctx.restart();
168 ctx.run();
169
170 BOOST_ASIO_CHECK(function_count == 1);
171 BOOST_ASIO_CHECK(handler_count == 1);
172

Callers

nothing calls this directly

Calls 7

restartMethod · 0.80
deferFunction · 0.50
bindFunction · 0.50
get_executorMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected