Shows how to use call_once_ keyword.
#include <xtd/xtd>
auto main() -> int {
console::write_line("(main) begin");
auto mre = manual_reset_event {};
auto thread_proc = [&] {
static auto cpt = 0;
console::write_line(" (thread_proc) call once {} times", cpt + 1);
};
console::write_line(" (thread_proc) running {} times", ++cpt);
if (cpt == 3) mre.set();
};
thread_pool::register_wait_for_single_object(mre, thread_proc, {}, 100, false);
mre.wait_one();
thread::join_all();
console::write_line("(main) end");
}
#define call_once_
The xtd keyword call_once_ can be used to execute a routine exactly once. This can be used to initial...
Definition call_once.hpp:50