From 181be50f885314b04f7419df7c9913b198376590 Mon Sep 17 00:00:00 2001 From: pixl Date: Wed, 24 Jun 2020 22:27:19 -0400 Subject: [PATCH] Use unique pointer for global device manager Changed from raw pointer to a unique_ptr, also renamed from finder to device_manager --- src/logid/DeviceManager.h | 2 +- src/logid/logid.cpp | 12 ++++++------ src/logid/logid.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/logid/DeviceManager.h b/src/logid/DeviceManager.h index 50f7c31..6305963 100644 --- a/src/logid/DeviceManager.h +++ b/src/logid/DeviceManager.h @@ -44,7 +44,7 @@ namespace logid std::map> _receivers; }; - extern DeviceManager* finder; + extern std::unique_ptr device_manager; } #endif //LOGID_DEVICEMANAGER_H \ No newline at end of file diff --git a/src/logid/logid.cpp b/src/logid/logid.cpp index 2d885f4..35274e1 100644 --- a/src/logid/logid.cpp +++ b/src/logid/logid.cpp @@ -39,10 +39,10 @@ std::string config_file = DEFAULT_CONFIG_FILE; LogLevel logid::global_loglevel = INFO; // Configuration* logid::global_config; -DeviceManager* logid::finder; +std::unique_ptr logid::device_manager; bool logid::kill_logid = false; -std::mutex logid::finder_reloading; +std::mutex logid::device_manager_reload; enum class Option { @@ -172,12 +172,12 @@ int main(int argc, char** argv) */ // Scan devices, create listeners, handlers, etc. - finder = new DeviceManager(); + device_manager = std::make_unique(); while(!kill_logid) { - finder_reloading.lock(); - finder_reloading.unlock(); - finder->run(); + device_manager_reload.lock(); + device_manager_reload.unlock(); + device_manager->run(); } return EXIT_SUCCESS; diff --git a/src/logid/logid.h b/src/logid/logid.h index c73b577..850721f 100644 --- a/src/logid/logid.h +++ b/src/logid/logid.h @@ -26,7 +26,7 @@ namespace logid // void reload(); extern bool kill_logid; - extern std::mutex finder_reloading; + extern std::mutex device_manager_reload; } #endif //LOGID_LOGID_H \ No newline at end of file