basic_deadline_timer.hpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. //
  2. // basic_deadline_timer.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_BASIC_DEADLINE_TIMER_HPP
  11. #define ASIO_BASIC_DEADLINE_TIMER_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #if defined(ASIO_HAS_BOOST_DATE_TIME) \
  17. || defined(GENERATING_DOCUMENTATION)
  18. #include <cstddef>
  19. #include "asio/basic_io_object.hpp"
  20. #include "asio/detail/handler_type_requirements.hpp"
  21. #include "asio/detail/throw_error.hpp"
  22. #include "asio/error.hpp"
  23. #include "asio/time_traits.hpp"
  24. #if defined(ASIO_ENABLE_OLD_SERVICES)
  25. # include "asio/deadline_timer_service.hpp"
  26. #else // defined(ASIO_ENABLE_OLD_SERVICES)
  27. # include "asio/detail/deadline_timer_service.hpp"
  28. # define ASIO_SVC_T detail::deadline_timer_service<TimeTraits>
  29. #endif // defined(ASIO_ENABLE_OLD_SERVICES)
  30. #include "asio/detail/push_options.hpp"
  31. namespace asio {
  32. /// Provides waitable timer functionality.
  33. /**
  34. * The basic_deadline_timer class template provides the ability to perform a
  35. * blocking or asynchronous wait for a timer to expire.
  36. *
  37. * A deadline timer is always in one of two states: "expired" or "not expired".
  38. * If the wait() or async_wait() function is called on an expired timer, the
  39. * wait operation will complete immediately.
  40. *
  41. * Most applications will use the asio::deadline_timer typedef.
  42. *
  43. * @par Thread Safety
  44. * @e Distinct @e objects: Safe.@n
  45. * @e Shared @e objects: Unsafe.
  46. *
  47. * @par Examples
  48. * Performing a blocking wait:
  49. * @code
  50. * // Construct a timer without setting an expiry time.
  51. * asio::deadline_timer timer(io_context);
  52. *
  53. * // Set an expiry time relative to now.
  54. * timer.expires_from_now(boost::posix_time::seconds(5));
  55. *
  56. * // Wait for the timer to expire.
  57. * timer.wait();
  58. * @endcode
  59. *
  60. * @par
  61. * Performing an asynchronous wait:
  62. * @code
  63. * void handler(const asio::error_code& error)
  64. * {
  65. * if (!error)
  66. * {
  67. * // Timer expired.
  68. * }
  69. * }
  70. *
  71. * ...
  72. *
  73. * // Construct a timer with an absolute expiry time.
  74. * asio::deadline_timer timer(io_context,
  75. * boost::posix_time::time_from_string("2005-12-07 23:59:59.000"));
  76. *
  77. * // Start an asynchronous wait.
  78. * timer.async_wait(handler);
  79. * @endcode
  80. *
  81. * @par Changing an active deadline_timer's expiry time
  82. *
  83. * Changing the expiry time of a timer while there are pending asynchronous
  84. * waits causes those wait operations to be cancelled. To ensure that the action
  85. * associated with the timer is performed only once, use something like this:
  86. * used:
  87. *
  88. * @code
  89. * void on_some_event()
  90. * {
  91. * if (my_timer.expires_from_now(seconds(5)) > 0)
  92. * {
  93. * // We managed to cancel the timer. Start new asynchronous wait.
  94. * my_timer.async_wait(on_timeout);
  95. * }
  96. * else
  97. * {
  98. * // Too late, timer has already expired!
  99. * }
  100. * }
  101. *
  102. * void on_timeout(const asio::error_code& e)
  103. * {
  104. * if (e != asio::error::operation_aborted)
  105. * {
  106. * // Timer was not cancelled, take necessary action.
  107. * }
  108. * }
  109. * @endcode
  110. *
  111. * @li The asio::basic_deadline_timer::expires_from_now() function
  112. * cancels any pending asynchronous waits, and returns the number of
  113. * asynchronous waits that were cancelled. If it returns 0 then you were too
  114. * late and the wait handler has already been executed, or will soon be
  115. * executed. If it returns 1 then the wait handler was successfully cancelled.
  116. *
  117. * @li If a wait handler is cancelled, the asio::error_code passed to
  118. * it contains the value asio::error::operation_aborted.
  119. */
  120. template <typename Time,
  121. typename TimeTraits = asio::time_traits<Time>
  122. ASIO_SVC_TPARAM_DEF2(= deadline_timer_service<Time, TimeTraits>)>
  123. class basic_deadline_timer
  124. : ASIO_SVC_ACCESS basic_io_object<ASIO_SVC_T>
  125. {
  126. public:
  127. /// The type of the executor associated with the object.
  128. typedef io_context::executor_type executor_type;
  129. /// The time traits type.
  130. typedef TimeTraits traits_type;
  131. /// The time type.
  132. typedef typename traits_type::time_type time_type;
  133. /// The duration type.
  134. typedef typename traits_type::duration_type duration_type;
  135. /// Constructor.
  136. /**
  137. * This constructor creates a timer without setting an expiry time. The
  138. * expires_at() or expires_from_now() functions must be called to set an
  139. * expiry time before the timer can be waited on.
  140. *
  141. * @param io_context The io_context object that the timer will use to dispatch
  142. * handlers for any asynchronous operations performed on the timer.
  143. */
  144. explicit basic_deadline_timer(asio::io_context& io_context)
  145. : basic_io_object<ASIO_SVC_T>(io_context)
  146. {
  147. }
  148. /// Constructor to set a particular expiry time as an absolute time.
  149. /**
  150. * This constructor creates a timer and sets the expiry time.
  151. *
  152. * @param io_context The io_context object that the timer will use to dispatch
  153. * handlers for any asynchronous operations performed on the timer.
  154. *
  155. * @param expiry_time The expiry time to be used for the timer, expressed
  156. * as an absolute time.
  157. */
  158. basic_deadline_timer(asio::io_context& io_context,
  159. const time_type& expiry_time)
  160. : basic_io_object<ASIO_SVC_T>(io_context)
  161. {
  162. asio::error_code ec;
  163. this->get_service().expires_at(this->get_implementation(), expiry_time, ec);
  164. asio::detail::throw_error(ec, "expires_at");
  165. }
  166. /// Constructor to set a particular expiry time relative to now.
  167. /**
  168. * This constructor creates a timer and sets the expiry time.
  169. *
  170. * @param io_context The io_context object that the timer will use to dispatch
  171. * handlers for any asynchronous operations performed on the timer.
  172. *
  173. * @param expiry_time The expiry time to be used for the timer, relative to
  174. * now.
  175. */
  176. basic_deadline_timer(asio::io_context& io_context,
  177. const duration_type& expiry_time)
  178. : basic_io_object<ASIO_SVC_T>(io_context)
  179. {
  180. asio::error_code ec;
  181. this->get_service().expires_from_now(
  182. this->get_implementation(), expiry_time, ec);
  183. asio::detail::throw_error(ec, "expires_from_now");
  184. }
  185. #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  186. /// Move-construct a basic_deadline_timer from another.
  187. /**
  188. * This constructor moves a timer from one object to another.
  189. *
  190. * @param other The other basic_deadline_timer object from which the move will
  191. * occur.
  192. *
  193. * @note Following the move, the moved-from object is in the same state as if
  194. * constructed using the @c basic_deadline_timer(io_context&) constructor.
  195. */
  196. basic_deadline_timer(basic_deadline_timer&& other)
  197. : basic_io_object<ASIO_SVC_T>(std::move(other))
  198. {
  199. }
  200. /// Move-assign a basic_deadline_timer from another.
  201. /**
  202. * This assignment operator moves a timer from one object to another. Cancels
  203. * any outstanding asynchronous operations associated with the target object.
  204. *
  205. * @param other The other basic_deadline_timer object from which the move will
  206. * occur.
  207. *
  208. * @note Following the move, the moved-from object is in the same state as if
  209. * constructed using the @c basic_deadline_timer(io_context&) constructor.
  210. */
  211. basic_deadline_timer& operator=(basic_deadline_timer&& other)
  212. {
  213. basic_io_object<ASIO_SVC_T>::operator=(std::move(other));
  214. return *this;
  215. }
  216. #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  217. /// Destroys the timer.
  218. /**
  219. * This function destroys the timer, cancelling any outstanding asynchronous
  220. * wait operations associated with the timer as if by calling @c cancel.
  221. */
  222. ~basic_deadline_timer()
  223. {
  224. }
  225. #if defined(ASIO_ENABLE_OLD_SERVICES)
  226. // These functions are provided by basic_io_object<>.
  227. #else // defined(ASIO_ENABLE_OLD_SERVICES)
  228. #if !defined(ASIO_NO_DEPRECATED)
  229. /// (Deprecated: Use get_executor().) Get the io_context associated with the
  230. /// object.
  231. /**
  232. * This function may be used to obtain the io_context object that the I/O
  233. * object uses to dispatch handlers for asynchronous operations.
  234. *
  235. * @return A reference to the io_context object that the I/O object will use
  236. * to dispatch handlers. Ownership is not transferred to the caller.
  237. */
  238. asio::io_context& get_io_context()
  239. {
  240. return basic_io_object<ASIO_SVC_T>::get_io_context();
  241. }
  242. /// (Deprecated: Use get_executor().) Get the io_context associated with the
  243. /// object.
  244. /**
  245. * This function may be used to obtain the io_context object that the I/O
  246. * object uses to dispatch handlers for asynchronous operations.
  247. *
  248. * @return A reference to the io_context object that the I/O object will use
  249. * to dispatch handlers. Ownership is not transferred to the caller.
  250. */
  251. asio::io_context& get_io_service()
  252. {
  253. return basic_io_object<ASIO_SVC_T>::get_io_service();
  254. }
  255. #endif // !defined(ASIO_NO_DEPRECATED)
  256. /// Get the executor associated with the object.
  257. executor_type get_executor() ASIO_NOEXCEPT
  258. {
  259. return basic_io_object<ASIO_SVC_T>::get_executor();
  260. }
  261. #endif // defined(ASIO_ENABLE_OLD_SERVICES)
  262. /// Cancel any asynchronous operations that are waiting on the timer.
  263. /**
  264. * This function forces the completion of any pending asynchronous wait
  265. * operations against the timer. The handler for each cancelled operation will
  266. * be invoked with the asio::error::operation_aborted error code.
  267. *
  268. * Cancelling the timer does not change the expiry time.
  269. *
  270. * @return The number of asynchronous operations that were cancelled.
  271. *
  272. * @throws asio::system_error Thrown on failure.
  273. *
  274. * @note If the timer has already expired when cancel() is called, then the
  275. * handlers for asynchronous wait operations will:
  276. *
  277. * @li have already been invoked; or
  278. *
  279. * @li have been queued for invocation in the near future.
  280. *
  281. * These handlers can no longer be cancelled, and therefore are passed an
  282. * error code that indicates the successful completion of the wait operation.
  283. */
  284. std::size_t cancel()
  285. {
  286. asio::error_code ec;
  287. std::size_t s = this->get_service().cancel(this->get_implementation(), ec);
  288. asio::detail::throw_error(ec, "cancel");
  289. return s;
  290. }
  291. /// Cancel any asynchronous operations that are waiting on the timer.
  292. /**
  293. * This function forces the completion of any pending asynchronous wait
  294. * operations against the timer. The handler for each cancelled operation will
  295. * be invoked with the asio::error::operation_aborted error code.
  296. *
  297. * Cancelling the timer does not change the expiry time.
  298. *
  299. * @param ec Set to indicate what error occurred, if any.
  300. *
  301. * @return The number of asynchronous operations that were cancelled.
  302. *
  303. * @note If the timer has already expired when cancel() is called, then the
  304. * handlers for asynchronous wait operations will:
  305. *
  306. * @li have already been invoked; or
  307. *
  308. * @li have been queued for invocation in the near future.
  309. *
  310. * These handlers can no longer be cancelled, and therefore are passed an
  311. * error code that indicates the successful completion of the wait operation.
  312. */
  313. std::size_t cancel(asio::error_code& ec)
  314. {
  315. return this->get_service().cancel(this->get_implementation(), ec);
  316. }
  317. /// Cancels one asynchronous operation that is waiting on the timer.
  318. /**
  319. * This function forces the completion of one pending asynchronous wait
  320. * operation against the timer. Handlers are cancelled in FIFO order. The
  321. * handler for the cancelled operation will be invoked with the
  322. * asio::error::operation_aborted error code.
  323. *
  324. * Cancelling the timer does not change the expiry time.
  325. *
  326. * @return The number of asynchronous operations that were cancelled. That is,
  327. * either 0 or 1.
  328. *
  329. * @throws asio::system_error Thrown on failure.
  330. *
  331. * @note If the timer has already expired when cancel_one() is called, then
  332. * the handlers for asynchronous wait operations will:
  333. *
  334. * @li have already been invoked; or
  335. *
  336. * @li have been queued for invocation in the near future.
  337. *
  338. * These handlers can no longer be cancelled, and therefore are passed an
  339. * error code that indicates the successful completion of the wait operation.
  340. */
  341. std::size_t cancel_one()
  342. {
  343. asio::error_code ec;
  344. std::size_t s = this->get_service().cancel_one(
  345. this->get_implementation(), ec);
  346. asio::detail::throw_error(ec, "cancel_one");
  347. return s;
  348. }
  349. /// Cancels one asynchronous operation that is waiting on the timer.
  350. /**
  351. * This function forces the completion of one pending asynchronous wait
  352. * operation against the timer. Handlers are cancelled in FIFO order. The
  353. * handler for the cancelled operation will be invoked with the
  354. * asio::error::operation_aborted error code.
  355. *
  356. * Cancelling the timer does not change the expiry time.
  357. *
  358. * @param ec Set to indicate what error occurred, if any.
  359. *
  360. * @return The number of asynchronous operations that were cancelled. That is,
  361. * either 0 or 1.
  362. *
  363. * @note If the timer has already expired when cancel_one() is called, then
  364. * the handlers for asynchronous wait operations will:
  365. *
  366. * @li have already been invoked; or
  367. *
  368. * @li have been queued for invocation in the near future.
  369. *
  370. * These handlers can no longer be cancelled, and therefore are passed an
  371. * error code that indicates the successful completion of the wait operation.
  372. */
  373. std::size_t cancel_one(asio::error_code& ec)
  374. {
  375. return this->get_service().cancel_one(this->get_implementation(), ec);
  376. }
  377. /// Get the timer's expiry time as an absolute time.
  378. /**
  379. * This function may be used to obtain the timer's current expiry time.
  380. * Whether the timer has expired or not does not affect this value.
  381. */
  382. time_type expires_at() const
  383. {
  384. return this->get_service().expires_at(this->get_implementation());
  385. }
  386. /// Set the timer's expiry time as an absolute time.
  387. /**
  388. * This function sets the expiry time. Any pending asynchronous wait
  389. * operations will be cancelled. The handler for each cancelled operation will
  390. * be invoked with the asio::error::operation_aborted error code.
  391. *
  392. * @param expiry_time The expiry time to be used for the timer.
  393. *
  394. * @return The number of asynchronous operations that were cancelled.
  395. *
  396. * @throws asio::system_error Thrown on failure.
  397. *
  398. * @note If the timer has already expired when expires_at() is called, then
  399. * the handlers for asynchronous wait operations will:
  400. *
  401. * @li have already been invoked; or
  402. *
  403. * @li have been queued for invocation in the near future.
  404. *
  405. * These handlers can no longer be cancelled, and therefore are passed an
  406. * error code that indicates the successful completion of the wait operation.
  407. */
  408. std::size_t expires_at(const time_type& expiry_time)
  409. {
  410. asio::error_code ec;
  411. std::size_t s = this->get_service().expires_at(
  412. this->get_implementation(), expiry_time, ec);
  413. asio::detail::throw_error(ec, "expires_at");
  414. return s;
  415. }
  416. /// Set the timer's expiry time as an absolute time.
  417. /**
  418. * This function sets the expiry time. Any pending asynchronous wait
  419. * operations will be cancelled. The handler for each cancelled operation will
  420. * be invoked with the asio::error::operation_aborted error code.
  421. *
  422. * @param expiry_time The expiry time to be used for the timer.
  423. *
  424. * @param ec Set to indicate what error occurred, if any.
  425. *
  426. * @return The number of asynchronous operations that were cancelled.
  427. *
  428. * @note If the timer has already expired when expires_at() is called, then
  429. * the handlers for asynchronous wait operations will:
  430. *
  431. * @li have already been invoked; or
  432. *
  433. * @li have been queued for invocation in the near future.
  434. *
  435. * These handlers can no longer be cancelled, and therefore are passed an
  436. * error code that indicates the successful completion of the wait operation.
  437. */
  438. std::size_t expires_at(const time_type& expiry_time,
  439. asio::error_code& ec)
  440. {
  441. return this->get_service().expires_at(
  442. this->get_implementation(), expiry_time, ec);
  443. }
  444. /// Get the timer's expiry time relative to now.
  445. /**
  446. * This function may be used to obtain the timer's current expiry time.
  447. * Whether the timer has expired or not does not affect this value.
  448. */
  449. duration_type expires_from_now() const
  450. {
  451. return this->get_service().expires_from_now(this->get_implementation());
  452. }
  453. /// Set the timer's expiry time relative to now.
  454. /**
  455. * This function sets the expiry time. Any pending asynchronous wait
  456. * operations will be cancelled. The handler for each cancelled operation will
  457. * be invoked with the asio::error::operation_aborted error code.
  458. *
  459. * @param expiry_time The expiry time to be used for the timer.
  460. *
  461. * @return The number of asynchronous operations that were cancelled.
  462. *
  463. * @throws asio::system_error Thrown on failure.
  464. *
  465. * @note If the timer has already expired when expires_from_now() is called,
  466. * then the handlers for asynchronous wait operations will:
  467. *
  468. * @li have already been invoked; or
  469. *
  470. * @li have been queued for invocation in the near future.
  471. *
  472. * These handlers can no longer be cancelled, and therefore are passed an
  473. * error code that indicates the successful completion of the wait operation.
  474. */
  475. std::size_t expires_from_now(const duration_type& expiry_time)
  476. {
  477. asio::error_code ec;
  478. std::size_t s = this->get_service().expires_from_now(
  479. this->get_implementation(), expiry_time, ec);
  480. asio::detail::throw_error(ec, "expires_from_now");
  481. return s;
  482. }
  483. /// Set the timer's expiry time relative to now.
  484. /**
  485. * This function sets the expiry time. Any pending asynchronous wait
  486. * operations will be cancelled. The handler for each cancelled operation will
  487. * be invoked with the asio::error::operation_aborted error code.
  488. *
  489. * @param expiry_time The expiry time to be used for the timer.
  490. *
  491. * @param ec Set to indicate what error occurred, if any.
  492. *
  493. * @return The number of asynchronous operations that were cancelled.
  494. *
  495. * @note If the timer has already expired when expires_from_now() is called,
  496. * then the handlers for asynchronous wait operations will:
  497. *
  498. * @li have already been invoked; or
  499. *
  500. * @li have been queued for invocation in the near future.
  501. *
  502. * These handlers can no longer be cancelled, and therefore are passed an
  503. * error code that indicates the successful completion of the wait operation.
  504. */
  505. std::size_t expires_from_now(const duration_type& expiry_time,
  506. asio::error_code& ec)
  507. {
  508. return this->get_service().expires_from_now(
  509. this->get_implementation(), expiry_time, ec);
  510. }
  511. /// Perform a blocking wait on the timer.
  512. /**
  513. * This function is used to wait for the timer to expire. This function
  514. * blocks and does not return until the timer has expired.
  515. *
  516. * @throws asio::system_error Thrown on failure.
  517. */
  518. void wait()
  519. {
  520. asio::error_code ec;
  521. this->get_service().wait(this->get_implementation(), ec);
  522. asio::detail::throw_error(ec, "wait");
  523. }
  524. /// Perform a blocking wait on the timer.
  525. /**
  526. * This function is used to wait for the timer to expire. This function
  527. * blocks and does not return until the timer has expired.
  528. *
  529. * @param ec Set to indicate what error occurred, if any.
  530. */
  531. void wait(asio::error_code& ec)
  532. {
  533. this->get_service().wait(this->get_implementation(), ec);
  534. }
  535. /// Start an asynchronous wait on the timer.
  536. /**
  537. * This function may be used to initiate an asynchronous wait against the
  538. * timer. It always returns immediately.
  539. *
  540. * For each call to async_wait(), the supplied handler will be called exactly
  541. * once. The handler will be called when:
  542. *
  543. * @li The timer has expired.
  544. *
  545. * @li The timer was cancelled, in which case the handler is passed the error
  546. * code asio::error::operation_aborted.
  547. *
  548. * @param handler The handler to be called when the timer expires. Copies
  549. * will be made of the handler as required. The function signature of the
  550. * handler must be:
  551. * @code void handler(
  552. * const asio::error_code& error // Result of operation.
  553. * ); @endcode
  554. * Regardless of whether the asynchronous operation completes immediately or
  555. * not, the handler will not be invoked from within this function. Invocation
  556. * of the handler will be performed in a manner equivalent to using
  557. * asio::io_context::post().
  558. */
  559. template <typename WaitHandler>
  560. ASIO_INITFN_RESULT_TYPE(WaitHandler,
  561. void (asio::error_code))
  562. async_wait(ASIO_MOVE_ARG(WaitHandler) handler)
  563. {
  564. // If you get an error on the following line it means that your handler does
  565. // not meet the documented type requirements for a WaitHandler.
  566. ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
  567. #if defined(ASIO_ENABLE_OLD_SERVICES)
  568. return this->get_service().async_wait(this->get_implementation(),
  569. ASIO_MOVE_CAST(WaitHandler)(handler));
  570. #else // defined(ASIO_ENABLE_OLD_SERVICES)
  571. async_completion<WaitHandler,
  572. void (asio::error_code)> init(handler);
  573. this->get_service().async_wait(this->get_implementation(),
  574. init.completion_handler);
  575. return init.result.get();
  576. #endif // defined(ASIO_ENABLE_OLD_SERVICES)
  577. }
  578. };
  579. } // namespace asio
  580. #include "asio/detail/pop_options.hpp"
  581. #if !defined(ASIO_ENABLE_OLD_SERVICES)
  582. # undef ASIO_SVC_T
  583. #endif // !defined(ASIO_ENABLE_OLD_SERVICES)
  584. #endif // defined(ASIO_HAS_BOOST_DATE_TIME)
  585. // || defined(GENERATING_DOCUMENTATION)
  586. #endif // ASIO_BASIC_DEADLINE_TIMER_HPP