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

Function deadline_timer_custom_allocation_test

test/deadline_timer.cpp:326–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324};
325
326void deadline_timer_custom_allocation_test()
327{
328 static boost::asio::io_context io_context;
329 struct timer
330 {
331 boost::asio::deadline_timer t;
332 timer() : t(io_context) {}
333 } timers[100];
334
335 int allocation_count = 0;
336
337 for (int i = 0; i < 50; ++i)
338 {
339 timers[i].t.expires_at(boost::posix_time::pos_infin);
340 timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
341 }
342
343 for (int i = 50; i < 100; ++i)
344 {
345 timers[i].t.expires_at(boost::posix_time::neg_infin);
346 timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
347 }
348
349 for (int i = 0; i < 50; ++i)
350 timers[i].t.cancel();
351
352 io_context.run();
353
354 BOOST_ASIO_CHECK(allocation_count == 0);
355}
356
357void io_context_run(boost::asio::io_context* ioc)
358{

Callers

nothing calls this directly

Calls 5

expires_atMethod · 0.45
async_waitMethod · 0.45
cancelMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected