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

Function main

example/cpp11/timers/time_t_timer.cpp:77–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 time_t_clock, time_t_wait_traits> time_t_timer;
76
77int main()
78{
79 try
80 {
81 boost::asio::io_context io_context;
82
83 time_t_timer timer(io_context);
84
85 timer.expires_after(std::chrono::seconds(5));
86 std::cout << "Starting synchronous wait\n";
87 timer.wait();
88 std::cout << "Finished synchronous wait\n";
89
90 timer.expires_after(std::chrono::seconds(5));
91 std::cout << "Starting asynchronous wait\n";
92 timer.async_wait(
93 [](const boost::system::error_code& /*error*/)
94 {
95 std::cout << "timeout\n";
96 });
97 io_context.run();
98 std::cout << "Finished asynchronous wait\n";
99 }
100 catch (std::exception& e)
101 {
102 std::cout << "Exception: " << e.what() << "\n";
103 }
104
105 return 0;
106}

Callers

nothing calls this directly

Calls 4

expires_afterMethod · 0.45
waitMethod · 0.45
async_waitMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected