timers.qbk

来自「Boost provides free peer-reviewed portab」· QBK 代码 · 共 54 行

QBK
54
字号
[/ / Copyright (c) 2003-2008 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 havecompleted. These deadlines may be expressed as absolute times, but are oftencalculated relative to the current time.As a simple example, to perform a synchronous wait operation on a timer using arelative time one may write:  io_service 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 atimer:  void handler(boost::system::error_code ec) { ... }  ...  io_service 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 be 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 boost_asio.reference.basic_deadline_timer basic_deadline_timer],[link boost_asio.reference.deadline_timer deadline_timer],[link boost_asio.reference.deadline_timer_service deadline_timer_service],[link boost_asio.tutorial.tuttimer1 timer tutorials].[endsect]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?