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

Method check_deadline

example/cpp11/timeouts/server.cpp:302–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300 }
301
302 void check_deadline(steady_timer& deadline)
303 {
304 auto self(shared_from_this());
305 deadline.async_wait(
306 [this, self, &deadline](const boost::system::error_code& /*error*/)
307 {
308 // Check if the session was stopped while the operation was pending.
309 if (stopped())
310 return;
311
312 // Check whether the deadline has passed. We compare the deadline
313 // against the current time since a new asynchronous operation may
314 // have moved the deadline before this actor had a chance to run.
315 if (deadline.expiry() <= steady_timer::clock_type::now())
316 {
317 // The deadline has passed. Stop the session. The other actors will
318 // terminate as soon as possible.
319 stop();
320 }
321 else
322 {
323 // Put the actor back to sleep.
324 check_deadline(deadline);
325 }
326 });
327 }
328
329 channel& channel_;
330 tcp::socket socket_;

Callers

nothing calls this directly

Calls 3

nowFunction · 0.50
async_waitMethod · 0.45
expiryMethod · 0.45

Tested by

no test coverage detected