From 07618f3777e96ae6bdc3246bfb14df45a2730bda Mon Sep 17 00:00:00 2001 From: zhao liwei Date: Tue, 23 Jun 2020 10:06:44 +0800 Subject: [PATCH] refactor: remove the unused struct io_engine (#512) --- src/core/core/service_engine.cpp | 22 ++++++++-------------- src/core/core/service_engine.h | 13 +++---------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/core/core/service_engine.cpp b/src/core/core/service_engine.cpp index f65bafbab7..ff9f39bff6 100644 --- a/src/core/core/service_engine.cpp +++ b/src/core/core/service_engine.cpp @@ -45,25 +45,21 @@ bool service_node::rpc_register_handler(task_code code, const char *extra_name, const rpc_request_handler &h) { - return _node_io.rpc->register_rpc_handler(code, extra_name, h); + return _rpc->register_rpc_handler(code, extra_name, h); } bool service_node::rpc_unregister_handler(dsn::task_code rpc_code) { - return _node_io.rpc->unregister_rpc_handler(rpc_code); + return _rpc->unregister_rpc_handler(rpc_code); } -error_code service_node::init_io_engine() +error_code service_node::init_rpc_engine() { // init rpc engine - _node_io.rpc = make_unique(this); - return ERR_OK; -} + _rpc = make_unique(this); -error_code service_node::start_io_engine_in_main() -{ // start rpc engine - return _node_io.rpc->start(_app_spec); + return _rpc->start(_app_spec); } dsn::error_code service_node::start_app() @@ -116,13 +112,11 @@ error_code service_node::start() _computation->create(_app_spec.pools); dassert(!_computation->is_started(), "task engine must not be started at this point"); - err = init_io_engine(); + // init rpc + err = init_rpc_engine(); if (err != ERR_OK) return err; - // start io engines (only timer, disk and rpc), others are started in app start task - start_io_engine_in_main(); - // start task engine _computation->start(); dassert(_computation->is_started(), "task engine must be started at this point"); @@ -134,7 +128,7 @@ error_code service_node::start() } // start rpc serving - _node_io.rpc->start_serving(); + _rpc->start_serving(); return err; } diff --git a/src/core/core/service_engine.h b/src/core/core/service_engine.h index 29afad40b4..dc7c94ab9d 100644 --- a/src/core/core/service_engine.h +++ b/src/core/core/service_engine.h @@ -60,18 +60,12 @@ class timer_service; // class service_node { -public: - struct io_engine - { - std::unique_ptr rpc; - }; - public: explicit service_node(service_app_spec &app_spec); ~service_node(); - rpc_engine *rpc() const { return _node_io.rpc.get(); } + rpc_engine *rpc() const { return _rpc.get(); } task_engine *computation() const { return _computation.get(); } void get_runtime_info(const std::string &indent, @@ -100,15 +94,14 @@ class service_node service_app_spec _app_spec; std::unique_ptr _computation; - io_engine _node_io; + std::unique_ptr _rpc; private: // the service entity is initialized after the engine // is initialized, so this should be call in start() void init_service_app(); - error_code init_io_engine(); - error_code start_io_engine_in_main(); + error_code init_rpc_engine(); }; typedef std::map> service_nodes_by_app_id;