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

Function bind_allocator_to_function_object_test

test/bind_allocator.cpp:83–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void bind_allocator_to_function_object_test()
84{
85 io_context ioc;
86
87 int count = 0;
88 int allocations = 0;
89
90 timer t(ioc, chronons::seconds(1));
91 t.async_wait(
92 bind_allocator(
93 test_allocator<int>(&allocations),
94 bindns::bind(&increment, &count)));
95
96 BOOST_ASIO_CHECK(count == 0);
97 BOOST_ASIO_CHECK(allocations == 1);
98
99 ioc.run();
100
101 BOOST_ASIO_CHECK(count == 1);
102 BOOST_ASIO_CHECK(allocations == 0);
103
104 t.async_wait(
105 bind_allocator(
106 test_allocator<int>(&allocations),
107 bind_allocator(
108 std::allocator<void>(),
109 bindns::bind(&increment, &count))));
110
111 BOOST_ASIO_CHECK(count == 1);
112 BOOST_ASIO_CHECK(allocations == 1);
113
114 ioc.restart();
115 ioc.run();
116
117 BOOST_ASIO_CHECK(count == 2);
118 BOOST_ASIO_CHECK(allocations == 0);
119}
120
121struct incrementer_token_v1
122{

Callers

nothing calls this directly

Calls 4

restartMethod · 0.80
bindFunction · 0.50
async_waitMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected