Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
refactor: remove the unused struct io_engine (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhao liwei authored Jun 23, 2020
1 parent 73b1bba commit 07618f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
22 changes: 8 additions & 14 deletions src/core/core/service_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<rpc_engine>(this);
return ERR_OK;
}
_rpc = make_unique<rpc_engine>(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()
Expand Down Expand Up @@ -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");
Expand All @@ -134,7 +128,7 @@ error_code service_node::start()
}

// start rpc serving
_node_io.rpc->start_serving();
_rpc->start_serving();

return err;
}
Expand Down
13 changes: 3 additions & 10 deletions src/core/core/service_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,12 @@ class timer_service;
//
class service_node
{
public:
struct io_engine
{
std::unique_ptr<rpc_engine> 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,
Expand Down Expand Up @@ -100,15 +94,14 @@ class service_node
service_app_spec _app_spec;

std::unique_ptr<task_engine> _computation;
io_engine _node_io;
std::unique_ptr<rpc_engine> _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<int, std::shared_ptr<service_node>> service_nodes_by_app_id;
Expand Down

0 comments on commit 07618f3

Please sign in to comment.