Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a Shutdown method to DeviceControllerFactory (#14723)
The new method would the symmetrical API for DeviceControllerFactory's already existing `Init()` API. What is the root of the problem? The problem we intend to solve is that we'd like to use `Shutdown()` method to shut down and clean up any memory/functionality enabled by `Init()` as opposed to waiting for the DeviceControllerFactory desctructor, which only happens once the program shuts down due to the nature of how DeviceControllerFactory is instantiated. DeviceControllerFactory can only be instantiated through ::GetInstance(), this method constructs DeviceControllerFactory only once for the life of the program (the constructor is a private method). Once the Init() is invoked, the `mSystemState` is allocated as shown in the following: ``` mSystemState = chip::Platform::New<DeviceControllerSystemState>(stateParams); ``` However, in DeviceControllerFactory's destructor, which currently is only invoked once the program shuts down, the deallocation of `mSystemState` is requested via `chip::Platform::Delete`. This can be problematic since the application will need to ensure `chip::Platform` memory stays initailized throughout the memory shutdown. Adding a shutdown methods allows the applications to have a symmetry between the initialization and shutdown sequence related to the DeviceControllerFactory
- Loading branch information