Skip to content

Commit

Permalink
Add a make_timer method
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Oct 15, 2024
1 parent d1cf9fc commit c719ef2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/appbase/application_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,22 @@ class application_t : public application_base {
return executor().get_io_service();
}

/**
* Create a timer with the main application io_context. Timer async_wait will execute on the main thread.
*
* Use with app().executor().wrap(priority::x, exec_queue::x, [](const boost::system::error_code& ec).
* For example:
* _timer.async_wait(app().executor().wrap(priority::high, exec_queue::read_write,
* [](const boost::system::error_code& ec) {
* if (!ec)
* // do something
* }));
*/
template<typename Timer>
auto make_timer() {
return Timer{get_io_service()};
}

void startup() {
application_base::startup(get_io_service());
}
Expand Down

0 comments on commit c719ef2

Please sign in to comment.