entity-manager: remove global io_context
Remove the global var
```
boost::asio::io_context io
```
and move it to be a local var in the main function.
Since boost::asio::io_context io is declared first, it in scope for the
entire program duration and should not cause any issues from that
perspective.
The io_context is passed through where needed. In case there is a class
already defined, the class now has a reference to the io_context to
avoid passing it through everywhere.
Tested: Capturing or passing a reference which is always valid should
not introduce any issues.
Tested on Tyan S8030:
```
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: Supermicro PWS 920P SQ 0
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: Supermicro PWS 920P SQ 1
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: chassis
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: MBX 1.57 Chassis
```
busctl tree output as before
Change-Id: Ie8f7d18c38d166c57a9cb645ab45c9103bbdff6e
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/entity_manager.hpp b/src/entity_manager/entity_manager.hpp
index 8490d1c..ba3914f 100644
--- a/src/entity_manager/entity_manager.hpp
+++ b/src/entity_manager/entity_manager.hpp
@@ -33,7 +33,8 @@
{
public:
explicit EntityManager(
- std::shared_ptr<sdbusplus::asio::connection>& systemBus);
+ std::shared_ptr<sdbusplus::asio::connection>& systemBus,
+ boost::asio::io_context& io);
std::shared_ptr<sdbusplus::asio::connection> systemBus;
sdbusplus::asio::object_server objServer;
@@ -41,6 +42,7 @@
nlohmann::json lastJson;
nlohmann::json systemConfiguration;
Topology topology;
+ boost::asio::io_context& io;
void propertiesChangedCallback();
void registerCallback(const std::string& path);