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

Method check_deadline

example/cpp11/timeouts/async_tcp_client.cpp:254–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252 }
253
254 void check_deadline()
255 {
256 if (stopped_)
257 return;
258
259 // Check whether the deadline has passed. We compare the deadline against
260 // the current time since a new asynchronous operation may have moved the
261 // deadline before this actor had a chance to run.
262 if (deadline_.expiry() <= steady_timer::clock_type::now())
263 {
264 // The deadline has passed. The socket is closed so that any outstanding
265 // asynchronous operations are cancelled.
266 socket_.close();
267
268 // There is no longer an active deadline. The expiry is set to the
269 // maximum time point so that the actor takes no action until a new
270 // deadline is set.
271 deadline_.expires_at(steady_timer::time_point::max());
272 }
273
274 // Put the actor back to sleep.
275 deadline_.async_wait(std::bind(&client::check_deadline, this));
276 }
277
278private:
279 bool stopped_ = false;

Callers

nothing calls this directly

Calls 6

nowFunction · 0.50
bindFunction · 0.50
expiryMethod · 0.45
closeMethod · 0.45
expires_atMethod · 0.45
async_waitMethod · 0.45

Tested by

no test coverage detected