MCPcopy Create free account
hub / github.com/bshoshany/thread-pool / check_member_function

Function check_member_function

tests/BS_thread_pool_test.cpp:1220–1287  ·  view source on GitHub ↗

* @brief Check that submitting member functions works. */

Source from the content-addressed store, hash-verified

1218 * @brief Check that submitting member functions works.
1219 */
1220void check_member_function()
1221{
1222 BS::thread_pool pool;
1223 logln("Checking that detach_task() works for a member function with no arguments or return value...");
1224 {
1225 flag_class flag(pool);
1226 pool.detach_task(
1227 [&flag]
1228 {
1229 flag.set_flag_no_args();
1230 });
1231 pool.wait();
1232 check(flag.get_flag());
1233 }
1234 logln("Checking that detach_task() works for a member function with one argument and no return value...");
1235 {
1236 flag_class flag(pool);
1237 pool.detach_task(
1238 [&flag]
1239 {
1240 flag.set_flag_one_arg(true);
1241 });
1242 pool.wait();
1243 check(flag.get_flag());
1244 }
1245 logln("Checking that submit_task() works for a member function with no arguments or return value...");
1246 {
1247 flag_class flag(pool);
1248 pool.submit_task(
1249 [&flag]
1250 {
1251 flag.set_flag_no_args();
1252 })
1253 .wait();
1254 check(flag.get_flag());
1255 }
1256 logln("Checking that submit_task() works for a member function with one argument and no return value...");
1257 {
1258 flag_class flag(pool);
1259 pool.submit_task(
1260 [&flag]
1261 {
1262 flag.set_flag_one_arg(true);
1263 })
1264 .wait();
1265 check(flag.get_flag());
1266 }
1267 logln("Checking that submit_task() works for a member function with no arguments and a return value...");
1268 {
1269 flag_class flag(pool);
1270 std::future<bool> flag_future = pool.submit_task(
1271 [&flag]
1272 {
1273 return flag.set_flag_no_args_return();
1274 });
1275 check(flag_future.get() && flag.get_flag());
1276 }
1277 logln("Checking that submit_task() works for a member function with one argument and a return value...");

Callers 1

mainFunction · 0.85

Calls 9

loglnFunction · 0.85
checkFunction · 0.85
set_flag_no_argsMethod · 0.80
waitMethod · 0.80
get_flagMethod · 0.80
set_flag_one_argMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected