Skip to content

Commit

Permalink
just use executor() for what get_executor() was doing
Browse files Browse the repository at this point in the history
  • Loading branch information
spoonincode committed Mar 11, 2024
1 parent 7266b2d commit 7fe91d3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions include/appbase/application_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,19 +352,19 @@ class application_t : public application_base {
*/
template <typename Func>
auto post(int priority, Func&& func) {
return get_executor().post(priority, std::forward<Func>(func));
return executor().post(priority, std::forward<Func>(func));
}

/**
* Wait until quit(), SIGINT or SIGTERM and then shutdown.
* Should only be executed from one thread.
*/
void exec() {
application_base::exec(get_executor());
application_base::exec(executor());
}

boost::asio::io_service& get_io_service() {
return get_executor().get_io_service();
return executor().get_io_service();
}

void startup() {
Expand All @@ -373,19 +373,15 @@ class application_t : public application_base {

application_t() : application_base(std::make_shared<executor_t>()) {
set_stop_executor_cb([&]() { get_io_service().stop(); });
set_post_cb([&](int prio, std::function<void()> cb) { get_executor().post(prio, std::move(cb)); });
set_post_cb([&](int prio, std::function<void()> cb) { executor().post(prio, std::move(cb)); });
}

executor_t& executor() {
return get_executor();
executor_t& executor() const {
return *static_cast<executor_t*>(executor_ptr.get());
}

private:
inline static std::unique_ptr<application_t> app_instance;

executor_t& get_executor() const {
return *static_cast<executor_t*>(executor_ptr.get());
}
};


Expand Down

0 comments on commit 7fe91d3

Please sign in to comment.