Use unique pointer for global device manager
Changed from raw pointer to a unique_ptr, also renamed from finder to device_manager
This commit is contained in:
parent
5f76ccc4ac
commit
181be50f88
|
@ -44,7 +44,7 @@ namespace logid
|
|||
std::map<std::string, std::shared_ptr<Receiver>> _receivers;
|
||||
};
|
||||
|
||||
extern DeviceManager* finder;
|
||||
extern std::unique_ptr<DeviceManager> device_manager;
|
||||
}
|
||||
|
||||
#endif //LOGID_DEVICEMANAGER_H
|
|
@ -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<DeviceManager> 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<DeviceManager>();
|
||||
|
||||
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;
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user