Sha256: acba28bfd4e24a5a60f3853cfc9eb21ba9091380a47672de0442031a81ddf8e4

Contents?: true

Size: 1.44 KB

Versions: 24

Compression:

Stored size: 1.44 KB

Contents

[/
 / Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[section:timers Timers]

Long running I/O operations will often have a deadline by which they must have
completed. These deadlines may be expressed as absolute times, but are often
calculated relative to the current time.

As a simple example, to perform a synchronous wait operation on a timer using a
relative time one may write:

  io_context i;
  ...
  deadline_timer t(i);
  t.expires_from_now(boost::posix_time::seconds(5));
  t.wait();

More commonly, a program will perform an asynchronous wait operation on a
timer:

  void handler(asio::error_code ec) { ... }
  ...
  io_context i;
  ...
  deadline_timer t(i);
  t.expires_from_now(boost::posix_time::milliseconds(400));
  t.async_wait(handler);
  ...
  i.run();

The deadline associated with a timer may also be obtained as a relative time:

  boost::posix_time::time_duration time_until_expiry
    = t.expires_from_now();

or as an absolute time to allow composition of timers:

  deadline_timer t2(i);
  t2.expires_at(t.expires_at() + boost::posix_time::seconds(30));

[heading See Also]

[link asio.reference.basic_deadline_timer basic_deadline_timer],
[link asio.reference.deadline_timer deadline_timer],
[link asio.tutorial.tuttimer1 timer tutorials].

[endsect]

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
couchbase-3.0.0-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.beta.1-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.beta.1 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.5-x86_64-linux ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.5-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.5-x86_64-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.5 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.4 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.3 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/timers.qbk
couchbase-3.0.0.alpha.2 ext/third_party/asio/asio/src/doc/overview/timers.qbk