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

Method run

example/cpp11/timeouts/blocking_udp_client.cpp:72–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70
71private:
72 void run(std::chrono::steady_clock::duration timeout)
73 {
74 // Restart the io_context, as it may have been left in the "stopped" state
75 // by a previous operation.
76 io_context_.restart();
77
78 // Block until the asynchronous operation has completed, or timed out. If
79 // the pending asynchronous operation is a composed operation, the deadline
80 // applies to the entire operation, rather than individual operations on
81 // the socket.
82 io_context_.run_for(timeout);
83
84 // If the asynchronous operation completed successfully then the io_context
85 // would have been stopped due to running out of work. If it was not
86 // stopped, then the io_context::run_for call must have timed out.
87 if (!io_context_.stopped())
88 {
89 // Cancel the outstanding asynchronous operation.
90 socket_.cancel();
91
92 // Run the io_context again until the operation completes.
93 io_context_.run();
94 }
95 }
96
97 static void handle_receive(
98 const boost::system::error_code& error, std::size_t length,

Callers 12

mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
initiateMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 4

restartMethod · 0.80
run_forMethod · 0.80
stoppedMethod · 0.45
cancelMethod · 0.45

Tested by

no test coverage detected