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

Function compose_1_completion_arg_test

test/composed.cpp:180–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178};
179
180void compose_1_completion_arg_test()
181{
182 namespace bindns = std;
183 using bindns::placeholders::_1;
184
185 boost::asio::io_context ioc;
186 int count = 0;
187 int result = 0;
188
189 async_1_completion_arg(ioc,
190 bindns::bind(&compose_1_arg_handler, &count, &result, _1));
191
192 // No handlers can be called until run() is called.
193 BOOST_ASIO_CHECK(!ioc.stopped());
194 BOOST_ASIO_CHECK(count == 0);
195 BOOST_ASIO_CHECK(result == 0);
196
197 ioc.run();
198
199 // The run() call will not return until all work has finished.
200 BOOST_ASIO_CHECK(ioc.stopped());
201 BOOST_ASIO_CHECK(count == 1);
202 BOOST_ASIO_CHECK(result == 42);
203
204 ioc.restart();
205 count = 0;
206 result = 0;
207
208 compose_1_arg_lvalue_handler lvalue_handler = { &count, &result };
209 async_1_completion_arg(ioc, lvalue_handler);
210
211 // No handlers can be called until run() is called.
212 BOOST_ASIO_CHECK(!ioc.stopped());
213 BOOST_ASIO_CHECK(count == 0);
214 BOOST_ASIO_CHECK(result == 0);
215
216 ioc.run();
217
218 // The run() call will not return until all work has finished.
219 BOOST_ASIO_CHECK(ioc.stopped());
220 BOOST_ASIO_CHECK(count == 1);
221 BOOST_ASIO_CHECK(result == 42);
222}
223
224//------------------------------------------------------------------------------
225

Callers

nothing calls this directly

Calls 5

restartMethod · 0.80
async_1_completion_argFunction · 0.70
bindFunction · 0.50
stoppedMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected