From 3f6c2b3621f4ec7fdf051f7c8e21faff31e2881d Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Wed, 4 Jan 2017 11:25:28 +0800 Subject: [PATCH] rm initConfigByGflags of PServerController, use stack value instead --- paddle/pserver/PServerController.cpp | 20 +++++++++----------- paddle/pserver/PServerController.h | 10 ++-------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/paddle/pserver/PServerController.cpp b/paddle/pserver/PServerController.cpp index 2d00019ce..8d2e026bc 100644 --- a/paddle/pserver/PServerController.cpp +++ b/paddle/pserver/PServerController.cpp @@ -60,18 +60,16 @@ PServerController::PServerController(const ParameterServerConfig& config) { PServerController::~PServerController() { this->join(); } -ParameterServerConfig* PServerController::initConfigByGflags() { - ParameterServerConfig* config = new ParameterServerConfig(); - config->set_nics(FLAGS_nics); - config->set_port(FLAGS_port); - config->set_ports_num(FLAGS_ports_num); - config->set_rdma_tcp(FLAGS_rdma_tcp); - return config; -} - PServerController* PServerController::createByGflags() { - auto& pServerConfig = *paddle::PServerController::initConfigByGflags(); - return create(pServerConfig); + ParameterServerConfig config; + + config.set_nics(FLAGS_nics); + config.set_rdma_tcp(FLAGS_rdma_tcp); + config.set_port(FLAGS_port); + config.set_ports_num(FLAGS_ports_num); + config.set_ports_num_for_sparse(FLAGS_ports_num_for_sparse); + + return create(config); } PServerController* PServerController::create( diff --git a/paddle/pserver/PServerController.h b/paddle/pserver/PServerController.h index 6fb7e0a31..cecf72900 100644 --- a/paddle/pserver/PServerController.h +++ b/paddle/pserver/PServerController.h @@ -21,7 +21,7 @@ limitations under the License. */ namespace paddle { -class PServerController { +class PServerController final { public: DISABLE_COPY(PServerController); @@ -58,13 +58,7 @@ public: void join(); private: - std::vector> pservers_; - - /** - * @brief create ParameterServerConfig from gflags, this is used for - * compatibility with the old usage of configuration by gflags. - */ - static ParameterServerConfig* initConfigByGflags(); + std::vector> pservers_; }; } // namespace paddle -- GitLab