You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by zh...@apache.org on 2022/03/07 02:28:28 UTC

[incubator-pegasus] branch master updated: refactor: make ctor/dtor function of singleton classes to be private (#921)

This is an automated email from the ASF dual-hosted git repository.

zhaoliwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new 6457b2f  refactor: make ctor/dtor function of singleton classes to be private (#921)
6457b2f is described below

commit 6457b2f171f8fd48a832aff4bf6c474f05ab04b2
Author: levy5307 <zl...@163.com>
AuthorDate: Mon Mar 7 10:28:18 2022 +0800

    refactor: make ctor/dtor function of singleton classes to be private (#921)
---
 src/base/value_schema_manager.h         |  1 +
 src/reporter/pegasus_counter_reporter.h |  9 ++++++---
 src/reporter/pegasus_io_service.h       | 14 ++++++++------
 src/test/bench_test/config.h            | 10 +++++++---
 src/test/function_test/global_env.h     |  1 +
 5 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/base/value_schema_manager.h b/src/base/value_schema_manager.h
index 189d89e..86ced84 100644
--- a/src/base/value_schema_manager.h
+++ b/src/base/value_schema_manager.h
@@ -36,6 +36,7 @@ public:
 
 private:
     value_schema_manager();
+    ~value_schema_manager() = default;
     friend class dsn::utils::singleton<value_schema_manager>;
 
     std::array<std::unique_ptr<value_schema>, data_version::VERSION_COUNT> _schemas;
diff --git a/src/reporter/pegasus_counter_reporter.h b/src/reporter/pegasus_counter_reporter.h
index d251b05..314dd78 100644
--- a/src/reporter/pegasus_counter_reporter.h
+++ b/src/reporter/pegasus_counter_reporter.h
@@ -54,15 +54,16 @@ enum class perf_counter_sink_t
     INVALID
 };
 
-class pegasus_counter_reporter : public ::dsn::utils::singleton<pegasus_counter_reporter>
+class pegasus_counter_reporter : public dsn::utils::singleton<pegasus_counter_reporter>
 {
 public:
-    pegasus_counter_reporter();
-    virtual ~pegasus_counter_reporter();
     void start();
     void stop();
 
 private:
+    pegasus_counter_reporter();
+    virtual ~pegasus_counter_reporter();
+
     void falcon_initialize();
     void prometheus_initialize();
 
@@ -97,6 +98,8 @@ private:
     std::shared_ptr<prometheus::Registry> _registry;
     std::unique_ptr<prometheus::Exposer> _exposer;
     std::map<std::string, prometheus::Family<prometheus::Gauge> *> _gauge_family_map;
+
+    friend class dsn::utils::singleton<pegasus_counter_reporter>;
 };
 } // namespace server
 } // namespace pegasus
diff --git a/src/reporter/pegasus_io_service.h b/src/reporter/pegasus_io_service.h
index 1b2cd1f..9ddcd03 100644
--- a/src/reporter/pegasus_io_service.h
+++ b/src/reporter/pegasus_io_service.h
@@ -31,9 +31,12 @@ namespace server {
 // TODO: seperate this into per-node service, so we can use
 // task::get_current_node for faster access to the nodes in all tasks
 // coz tasks may run in io-threads when [task.xxx] allow_inline is true
-class pegasus_io_service : public ::dsn::utils::singleton<pegasus_io_service>
+class pegasus_io_service : public dsn::utils::singleton<pegasus_io_service>
 {
 public:
+    boost::asio::io_service ios;
+
+private:
     pegasus_io_service()
     {
         _io_service_worker_count = 2;
@@ -53,11 +56,10 @@ public:
         }
     }
 
-    boost::asio::io_service ios;
-
-private:
     int _io_service_worker_count;
     std::vector<std::shared_ptr<std::thread>> _workers;
+
+    friend class dsn::utils::singleton<pegasus_io_service>;
 };
-}
-} // namespace
+} // namespace server
+} // namespace pegasus
diff --git a/src/test/bench_test/config.h b/src/test/bench_test/config.h
index f916944..f207b79 100644
--- a/src/test/bench_test/config.h
+++ b/src/test/bench_test/config.h
@@ -26,10 +26,8 @@
 namespace pegasus {
 namespace test {
 /** Thread safety singleton */
-struct config : public ::dsn::utils::singleton<config>
+struct config : public dsn::utils::singleton<config>
 {
-    config();
-
     std::string pegasus_cluster_name;
     std::string pegasus_app_name;
     // Pegasus read/write/delete timeout in milliseconds
@@ -50,6 +48,12 @@ struct config : public ::dsn::utils::singleton<config>
     uint64_t seed;
     // Default environment suitable for the current operating system
     rocksdb::Env *env;
+
+private:
+    config();
+    ~config() = default;
+
+    friend class dsn::utils::singleton<config>;
 };
 } // namespace test
 } // namespace pegasus
diff --git a/src/test/function_test/global_env.h b/src/test/function_test/global_env.h
index 812ee23..8bed6ad 100644
--- a/src/test/function_test/global_env.h
+++ b/src/test/function_test/global_env.h
@@ -33,6 +33,7 @@ private:
     global_env();
     global_env(const global_env &other) = delete;
     global_env(global_env &&other) = delete;
+    ~global_env() = default;
 
     void get_hostip();
     void get_dirs();

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org